【发布时间】:2021-08-12 02:56:56
【问题描述】:
我有问题。我想找到几个使用 Selenium 的网站的登录页面。为此,我尝试转到页面并单击带有“登录”、“登录”等文本的按钮。这适用于 Netflix。示例:
代码网站:Netflix.com
<a href="/login" class="authLinks redButton" data-uia="header-login-link">Sign In</a>
我的代码来检测按钮:
result = "https://www.microsoft.com"
driver.get(result)
elem = driver.find_element_by_link_text('Sign In').click
print(driver.current_url) # returns the website: https://www.netflix.com/de-en/login
现在我在 Microsoft.com 网站上进行尝试。网站代码作为图片:
如果我现在将包含查询更改为:
driver.find_element_by_link_text('Sign in').click # small "in"
Selenium 没有找到任何元素。我尝试了 Selenium 提供的许多不同选项,例如:
- find_element_by_id
- find_element_by_name
- find_element_by_link_text
- ...
例如:[https://selenium-python.readthedocs.io/locating-elements.html]
我的目标是使用“登录、登录”等文本信息来找到按钮并按下它。
非常感谢您的帮助
【问题讨论】:
标签: python python-3.x selenium selenium-webdriver