Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k views
in Technique[技术] by (71.8m points)

Python Selenium unexpected search outside the element

When I try to find elements inside the current element, the search occurs in the whole web page

For example I get some element:

year_block = browser.find_element_by_xpath('some condition')

There are several similar elements of such kind but I make sure that I've got the proper element using:

print(year_block.get_attribute('innerHTML'))

And then I need to find list of elements inside "year_block" I use:

plant_id_block_list = year_block.find_elements_by_xpath("//*[contains(text(), 'Plant number')]/following-sibling::input")

But in result I get the list of all such elements on a page instead of such elements only inside "year_block"

Where is the problem?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...