简体   繁体   English

使用 Python 查找驱动程序元素

[英]Find driver element with Python

I am trying to download a file from MS Edge.我正在尝试从 MS Edge 下载文件。 The webpage is protected by a username and a password.该网页受用户名和密码保护。 I am able to open up MS Edge, and navigate to the appropriate page, however, I can't navigate the UserName and PassWord box.我能够打开 MS Edge,并导航到相应的页面,但是,我无法导航用户名和密码框。

An error appears as follows:出现错误如下:

TypeError: Object of type builtin_function_or_method is not JSON serializable类型错误:builtin_function_or_method 类型的 Object 不是 JSON 可序列化的

I have tried a larger program, but broke it down to the following simple steps, since I am in debugging-mode:我尝试了一个更大的程序,但由于我处于调试模式,所以将其分解为以下简单步骤:

import time
from selenium import webdriver

driver = webdriver.Edge() #Edge opens

time.sleep(3)

driver.get("my_URL") #Webpage opens

time.sleep(3)

id_box = driver.find_element(id,"correct_id") #Error Occurs

You'll need to search like that:您需要这样搜索:

from selenium.webdriver.common.by import By


id_box = driver.find_element(By.ID,"correct_id")

Because only id isn't a valid object.因为只有id不是有效的 object。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 element selenium python chrome 驱动程序中查找元素 - find element inside element selenium python chrome driver 硒 Python 使用 driver.find_element_by_xpath() 显示 DeprecationWarnings - Seleneium Python shows DeprecationWarnings with driver.find_element_by_xpath() Selenium - driver.find_element_by_css_selector无法找到元素(python) - Selenium - driver.find_element_by_css_selector can't find the element (python) Python Selenium driver.find_element_by_xpath 在 iframe 中找不到元素 - Python Selenium driver.find_element_by_xpath can't find element within iframe Python Selenium driver.find_element().text 返回空字符串,但文本在 driver.page_source 中可见 - Python Selenium driver.find_element().text returns empty string, but text is visible in the driver.page_source Python CRON找不到MySQL驱动程序 - Python CRON not find the MySQL Driver 登录网站后,Selenium 驱动程序找不到任何元素 [Python] - Selenium driver can't find any element after logging into a website [Python] 无法使用 Selenium 驱动程序在 XPath 中找到元素 - Can not find element in XPath with Selenium driver (Selenium)使用驱动程序查找元素时遇到问题 - Having problem with the usage of driver find element by (Selenium) 与 selenium driver.find_element 不一致 - Inconsistency with selenium driver.find_element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM