我正在尝试通过硒(我将尝试使用ML解决的验证码)注册到mail.protonmail。
但是我发现自己花了数小时去做一些我认为会花费几分钟的事情。
在我点击创建帐户后-
我试图只是找到它的xpath / id,但似乎没有找到它。
它没有检测到新的窗口/警报,所以我现在有点绝望了...
如果有帮助,请参见以下HTML代码:
<button id="confirmModalBtn" autofocus="" class="pm_button primary modal-footer-button">Confirm</button>
我做了什么:
web = webdriver.Chrome(executable_path=r"D:\geckodriver \chromedriver.exe")
web.get(r'https://mail.protonmail.com/create/new?language=en')
# filling the data and getting to message i posted above..
accept_ele = web.find_element_by_class_name('pm_button primary modal-footer-button') # doesnt work
accept_ele = web.find_element_by_xpath('/html/body/div[1]/form/div[2]/button[2]') # doesnt work
答案 0 :(得分:0)
您可以尝试调用WebDriverWait并使用按钮的ID在此处找到元素:
from selenium.webdriver.support import expected_conditions as EC
accept_ele = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@id='confirmModalBtn']")))
我导航到您发布的网站,并复制了您在屏幕快照中显示的弹出窗口。我可以使用上面提供的XPath找到该元素:
答案 1 :(得分:0)
问题是我忘了切换回默认帧。
永远不要忘记切换回去。