0

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

2 Answers 2

1

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')]")):
    print("WebElement exists")
else:
    print("WebElement was not detected")
Sign up to request clarification or add additional context in comments.

Comments

0

You should use .text of your WebElement to check what you want. For example :

for td in driver.find_elements_by_xpath("//tbody/td"):
    if '5551110050' in td.text:
        print('OK')

I hope it'll work on your side !

2 Comments

Thanks but not my mind, I need a str "1/6/2021 3:00PM " and "5551110050" and "933" all match in 1 row. I need to check they all appear in a row or not.
Ok I see do you have any example of the HTML code containing all those informations ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.