0
我正在使用Python和Selenium。我的问题是我无法打开弹出的模式,我无法点击它中的按钮。如何使用Selenium在Python中切换到模态
这是模态的元素:
这是我的代码:
减去当然
browser = webdriver.Chrome(executable_path="D:\\sasdsa\\automate\\chromedriver_win32\\chromedriver.exe")
user_name = browser.find_element_by_xpath("//input[@id='username']")
user_name.send_keys("test.employee")
##Password
pass_word = browser.find_element_by_xpath("//input[@id='password']")
pass_word.send_keys("123")
##log_in = browser.find_element_by_css_selector(".btn")
log_in = browser.find_element_by_xpath("//button[@class='btn btn-sm btn-primary btn-block']")
log_in.click()
##punch
#driver.find_element_by_id("//@id='product_view')
#To open the modal
punch_in = browser.find_element_by_xpath("//button[@class='btn btn-success btn-sm pull-right']")
punch_in.click()
#cant switch to the modal to access the button
browser.switch_to_frame("product_view")
punch_in2 = browser.find_element_by_xpath("//button[@id='save_me']")
punch_in2.click()
你为什么试图切换到'div'作为'iframe'? – Andersson
那么我该怎么办?im试着从主页面切换到模式... –
以及它应该是什么代码? –