python - Python Selenium 不可能,试过 id,类找不到 XPath
问题描述
我正在尝试在用户名框中输入带有文本(电子邮件)的字段。但是,它没有与之交互。我在try
&except
声明中有它,但它只吐出异常。
网站是account.protonmail.com/signup
我已经尝试了一切:xpath
, class
, id
,但没有任何效果。我快疯了!密码工作正常:
不工作:
driver.find_element_by_xpath('//*[@id="username"]').send_keys(password)
是否有效:
driver.find_element_by_xpath('//*[@id="repeat-password"]').send_keys(password)
是的,我确实等到 JavaScript 完成运行。
解决方案
您尝试访问的元素位于 iframe 内。首先你需要像这样切换到框架
driver.switch_to.frame(driver.find_element_by_xpath("//iframe[contains(@src,'account-api.protonmail.com')]"))
推荐阅读
- laravel - 访问更多数据
- django - 在 Django 中运行涉及第三方服务的后台任务
- css - 如果在带有 CSS 的悬停动画之后单击,则保持结束动画宽度
- android - ViewModelScope 被永久取消了?
- java - 如何拆分列表
- python - 这种介数计算正确吗?
- oracle - Oracle BI Publisher .RTF 模板中的嵌套循环
- sql-server - T-SQL 中使用的“when 关键字”是什么?
- python - 将 AWS Lamba 上的 Python/Zappa 项目连接到 Mongodb Atlas
- vba - 在不会更改的临时变量中捕获表值