The following code opens a page and then logins in:
self.driver.get(target_url)
login = self.driver.find_element_by_name("login")
login.send_keys("user1")
password = self.driver.find_element_by_name("password")
password.send_keys("password123")
login.submit()
How do I check if the page is switched to another page after submitting the form?
For Selenium to switch to a particular window, one needs to use the switch_to_window method. Pass the window handle ID of the target tab where the user wants to switch as an argument to that method.
Class ElementNotInteractableExceptionThrown to indicate that although a WebElement is present on the DOM, it is not in a state that can be interacted with. This includes an element that is not displayed or whose center point can not be scrolled into the viewport.
Use an explicit wait with an expected condition to tell when one of your login elements has gone stale:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
self.driver.get(targeturl)
login = self.driver.find_element_by_name("login")
login.send_keys("user1")
password = self.driver.find_element_by_name("password")
password.send_keys("password123")
login.submit()
WebDriverWait(self.driver, timeout).until(EC.staleness_of(login))
while(self.driver.getCurrentUrl() != nextPageUrl)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With