python - 无法使用 Selenium 单击登录按钮
问题描述
我曾尝试使用.click()
,.submit()
和driver.get()
,但似乎没有任何效果。该网站是 gosgc.com
<div 是:
<!-- -->
<div_ngcontent-c1=""class="user user--login">
<a_ngcontent-c1=""class="recover-username"href="/recover- user"routerlink="/recover-user" routerlinkactive="menu__item--
active">Forgot Username?</a>
<a_ngcontent-c1=""class="button">Login</a>
</div>
谢谢您的帮助!
解决方案
请尝试以下方法之一:
# catching the element (login button) using xpath
driver.find_element_by_xpath("/html/body/sgc-web/div/general- layout/div/div/div[3]/a[2]").click()
# catching the element (login button) using CSS Selector
driver.find_element_by_css_selector("body > sgc-web > div > general-layout > div > div > div.user.user--login > a.button").click()
# catching the element (login button) using class name
driver.find_element_by_class_name("button").click()
# catching the element (login button) using link text
driver.find_element_by_link_text("Login").click()
推荐阅读
- mongodb - 无法从嵌套数组中提取并使用 MongoTemplate 查询返回子文档
- c# - XML Serializer 获取对象类型的目的是什么?
- apache-spark - S3 - Spark - Avro 读取问题
- r - 在 igraph 网络中显示一个标签 pr 组
- amazon-redshift - 访问 Redshift 外部表所需的最低权限
- python - 未传递拟合参数时在Seaborn distplot中获取拟合曲线的参数
- cxf - Apache Cxf Webclient 在 Tomee 8 中无法按预期工作
- unity3d - 什么可能导致 PlayerPrefs 不保存字符串?
- java - TabLayout 中点之间的空间
- xamarin.forms - 仅限 Caliburn.Micro .NET Standard、Xamarin.Forms(iOS 和 Android),目标是哪个 .NET Standard 版本?