-1

I have plain HTML text <b>text</b> on the webpage. With Selenium WebDriver, I need to make it easy to check that the text is on the webpage. I can find an element using XPath, but I don't know how to make it an assertion on it.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
Tomasito
  • 306
  • 2
  • 15
  • 2
    What guides have you read on assertions? Have you googled assert libraries that are available in python and read their docs? What examples did you find? After you've done all this, if you still don't have your answer, update your question and put specifics of what you've tried and what didn't work. This site and the internet already has a TON of examples of what you are asking. There's nothing unique there. – JeffC Jun 17 '19 at 15:52

1 Answers1

2

Python:

driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)

text_tag = wait.until(EC.presence_of_element_located((By.XPATH,"the xpath to <b>text</b>")))
assert text_tag.text == "text"

Hope this helps you!

Community
  • 1
  • 1
Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38