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
267 views
in Technique[技术] by (71.8m points)

Check that a row (text) exists on a table in web by selenium (with Python)

enter image description here

I need to check that (the line what is being bordered) is appeared on web. I used xpath //td[6] to select this row but I don't know how to check whether text "1/06/2021 3:00PM 5551110050 933 and so on" is exist on this page.

I tried using //td[contains(text(),'5551110050')] but only select 1 elements, I need to concatenate many text to check this row

Regards


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

1 Answer

0 votes
by (71.8m points)

Use the following xpath which will identify the row based on string.

//tr[contains(.,'1/6/2021 3:00PM') and contains(.,'5551110050') and contains(.,'933')]

Check the length count if it more than 0 then Item Found else not

if len(driver.find_elements_by_xpath("//tr[contains(.,'1/6/2021 3:00PM') and contains(.,'5551110050') and contains(.,'933')]"))>0:
    print("Item Found")
else:
    print("There is no such item")

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

2.1m questions

2.1m answers

60 comments

57.0k users

...