Selenium Open Popup [Python]

I am trying to click a link:

driver.find_element_by_css_selector("a[href='javascript:openhistory('AXS0077')']").click()

This works well if the link opens in a new window, but in this case the link does open a popup. When I try to click a link using this method using selenium, it gives me an error:

Message: u "This selector a [href = 'javascript: openhistory (' AXS0077 ')'] is either invalid or does not use WebElement. The following error occurred: \ nInvalidSelectorError: Invalid or illegal selector was specified"

Is not it? because I think there can be several ways to deal with pop-ups.

+4
source share
2

css , :

driver.find_element_by_css_selector("a[href^='javascript']").click()

. , , .

+2

using find_by_xpath

popups

firebug element xpath.

, , .

from selenium import webdriver

baseurl="http://www.globalrph.com/davescripts/popup.htm"

dr = webdriver.Firefox()
dr.get(baseurl)
dr.find_element_by_xpath("/html/body/div/center/table/tbody/tr[7]/td/div/table/tbody/tr/td[2]/div[1]/form/table/tbody/tr[4]/td[1]/a").click()
0

Source: https://habr.com/ru/post/1542456/


All Articles