I am using my terminal to run an automated test, and I want to check that the word is inside the URL. I am thinking maybe I have a syntax error as I am new to using selenium.
In VSCode this is what I have so far, and I was able to successfully get the chrome browser to open as well as have it input the site name, but I am unable to get it to scan the URL string. Could you help explain what is the issue?
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support import expected_conditions as ECimport unittestimport time# Define the MyTestCase classclass MyTestCase(unittest.TestCase): def setUp(self): self.browser = webdriver.Chrome() self.addCleanup(self.browser.quit) def test_search_bar(self): self.browser.get('http://www.google.com') # Wait for the search bar element to be interactable wait = WebDriverWait(self.browser, 10) search_bar = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[type="text"]'))) # Use "text" instead of "textarea" search_bar.send_keys('Amazon.com'+ Keys.ENTER) self.assertIn('Amazon.com', search_bar.get_attribute('value')) # Wait for the URL to update time.sleep(2) self.assertIn('Amazon', self.browser.current_url) # Check for "Amazon" in the URLif __name__ == '__main__': unittest.main(verbosity=2)