mherrmann/helium

Ask, how to traverse the li node and get its text value or attribute value via helium?

Opened this issue · 0 comments

My attempt:

import helium as he

li_data_list = he.find_all('.list-wrapper')
for i in range(len(li_data_list)):
    # I want to get the time text
    # try method 1, but nok
    driver = he.get_driver()
    time_text = driver.find_element_by_xpath("//div[@class='course-info']")
    print(i, time_text)    # but two output is the same value : "Time: 2021-6-2 20:30\nCourse: Unit 5-Lesson 7-ABC Music\nTeacher: Tom T\nStatus: Normal End"

    # how can I traverse the <p> <li> node and get its text value or attribute value via helium?

Expected output:
image

html code snippet:

<ul date-z-235abcff="" class="list-wrapper">
    <li date-z-235abcff="" class="title-wrapper">
	    <span date-z-235abcff="" class="course">Course</span> 
		<span date-z-235abcff="" class="detail">Detail</span> 
		<span date-z-235abcff="" class="comment-a">Comment1</span> 
		<span date-z-235abcff="" class="comment-b">Comment2</span>
	</li> 
	<li date-z-235abcff="" class="item-wrapper">
	    <div date-z-235abcff="" class="course-info">
		    <img date-z-235abcff="" src="https://www.python.org/static/img/python-logo.png" alt="" class="teacher-img"> 
			<div date-z-235abcff="" class="info">
			    <p date-z-235abcff="">Time: 2021-6-2 20:30</p> 
				<p date-z-235abcff="">Course: Unit 5-Lesson 7-ABC Music</p> <!----> 
				<p date-z-235abcff="">Teacher:
                    <a date-z-235abcff="">Tom T</a>
				</p> 
				<p date-z-235abcff="">Status: Normal End</p>
			</div>
		</div> 
		<div date-z-235abcff="" class="detail-info">
		    <div date-z-235abcff="" class="cell-wrapper">
			    <a date-z-235abcff="" href="https://docs.python.org/3/tutorial/index.html" class="class-content">detail-1</a> <!----> 
				<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/appetite.html" class="replay">detail-2</a> 
				<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/interpreter.html" target="_blank" class="report">detail-3</a> <!---->
			</div>
		</div> 
		<div date-z-235abcff="" class="comment-a-info">
		    <div date-z-235abcff="" class="cell-wrapper">
			    <a date-z-235abcff="" href="https://docs.python.org/3/tutorial/introduction.html" target="_blank">Comment1</a>
			</div>
		</div> 
		<div date-z-235abcff="" class="comment-b-info">
		    <div date-z-235abcff="" class="cell-wrapper">
			    <a date-z-235abcff="" href="https://docs.python.org/3/tutorial/controlflow.html" class="button">Comment2</a>
			</div>
		</div>
	</li>
	<li date-z-235abcff="" class="item-wrapper">
	    <div date-z-235abcff="" class="course-info">
		    <img date-z-235abcff="" src="https://github.com/mherrmann/selenium-python-helium/blob/master/docs/helium-demo.gif" alt="" class="teacher-img"> 
			<div date-z-235abcff="" class="info">
			    <p date-z-235abcff="">Time: 2021-5-2 20:30</p> 
				<p date-z-235abcff="">Course: Unit 3-Lesson 8-Hello Python</p> <!----> 
				<p date-z-235abcff="">Teacher:
                    <a date-z-235abcff="">Jim T</a>
				</p> 
				<p date-z-235abcff="">Status: Normal End</p>
			</div>
		</div> 
		<div date-z-235abcff="" class="detail-info">
		    <div date-z-235abcff="" class="cell-wrapper">
			    <a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/blob/master/README.md" class="class-content">detail-1</a> <!----> 
				<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/issues" class="replay">detail-2</a> 
				<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/pulls" target="_blank" class="report">detail-3</a> <!---->
			</div>
		</div> 
		<div date-z-235abcff="" class="comment-a-info">
		    <div date-z-235abcff="" class="cell-wrapper">
			    <a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/security" target="_blank">Comment1</a>
			</div>
		</div> 
		<div date-z-235abcff="" class="comment-b-info">
		    <div date-z-235abcff="" class="cell-wrapper">
			    <a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/pulse" class="button">Comment2</a>
			</div>
		</div>
	</li>
	...... (multiple <li> </li> groups, e.g. it has 10+)
</ul>