How to select the most recent browsing window in python selenium -
when run following code, opens 2 browsing windows; second automatically open when code hit 'submitorder' button.
from selenium import webdriver selenium.webdriver.common.keys import keys browser = webdriver.firefox() url = 'http://example.com' browser.get(url) browser.find_element_by_id('submitorder').click() now have hit 'checkout' button in second (i.e, recent browsing window). following code gives error no such element.
browser.find_element_by_id('checkout').click() how can select recent browsing window (i.e., not previous one)?
for clicking on checkout button, you'll first have switch window button belongs , perform action on button.
driver.switch_to_window(handle) or
driver.switch_to_window("windowname") windowname details
all calls driver interpreted being directed particular window. how know window’s name? take @ javascript or link opened it: <a href="somewhere.html" target="windowname">click here open new window</a> for more details, refer http://selenium-python.readthedocs.org/navigating.html#moving-between-windows-and-frames
Comments
Post a Comment