为什么有些网站不能使用Selenium chrom实现自动化

2024-10-02 22:37:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试自动化https://myaccount.payoneer.com/MainPage/SetAccount.aspx网页,但不明白为什么网站不能导航到下一页

我的脚本正在打开页面->;输入用户和密码->;单击“继续”按钮,但单击后没有显示任何内容。虽然手动复制相同的步骤效果很好。对于这类网站,我是否缺少任何浏览器设置?我不知所措

import time
from selenium import webdriver


options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=C:\\Users\\Yongeei\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 5") #Path to your chrome profile
w = webdriver.Chrome(executable_path="D:\\hoc tool\\Day 2\\chromedriver.exe", chrome_options=options)
w.get('https://myaccount.payoneer.com/MainPage/SetAccount.aspx')
time.sleep(5)
username = w.find_element_by_id('username')
username.send_keys('username')
time.sleep(1)
passw = w.find_element_by_name('password')
passw.send_keys('password')
passw.submit()

Tags: httpsimportgtcomtime网站usernameoptions
1条回答
网友
1楼 · 发布于 2024-10-02 22:37:25

我尝试了你的步骤在Java和它似乎提交,但我没有一个帐户,所以我可以进入下一页无论如何

对于这种形式的提交,我通常会尝试以下几点:

  • password.submit()
  • 在密码字符串的末尾添加一个“\n”(或sendKeys(Keys.ENTER))
  • 单击“登录”按钮
  • 如果最后一个函数不能与普通的click()函数一起使用,请尝试使用webdriver执行js脚本driver.execute_script("document.getElementById('login_button').click()")

祝你好运

相关问题 更多 >