-1

This code is from:https://selenium-python.readthedocs.io/getting-started.html

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element(By.NAME, "q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

assert "Python" in driver.title //i don't understand this line what is

chino
  • 29
  • 4
  • Does this answer your question? [What is the use of "assert" in Python?](https://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python) – Keith Jul 11 '22 at 05:13

1 Answers1

0

Assert statements are used as a sort of quick check of logical condition. In this case, if the string "Python" is not in the driver.title string, an exception will be raised.

The assert statement can be found here

labroid
  • 452
  • 4
  • 14