简体   繁体   English

我如何在 python selenium 中输入我的登录名

[英]how I can enter my login in python selenium

在此处输入图片说明

I try with :我尝试:

WebDriverWait(browser.window_handles[-1], 20).until(EC.presence_of_element_located((By.ID, "pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername"))).send_keys("xxxxx")

Message Error : AttributeError: 'str' object has no attribute 'find_element'消息错误:AttributeError:“str”对象没有“find_element”属性

browser.find_element_by_id("pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername").send_keys("xxxxxxx")

Message Error : AttributeError: 'NoneType' object has no attribute 'send_keys'消息错误:AttributeError:'NoneType' 对象没有属性 'send_keys'

This这个

WebDriverWait(browser.window_handles[-1], 20).until(EC.presence_of_element_located((By.ID, "pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername"))).send_keys("xxxxx")

should be应该

WebDriverWait(browser, 20).until(EC.visibility_of_element_located((By.ID, "pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername"))).send_keys("xxxxx")

This error这个错误

AttributeError: 'NoneType' object has no attribute 'send_keys'

is cause browser.find_element_by_id("pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername") did not return any web element so, we have got NoneType .是因为browser.find_element_by_id("pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername")没有返回任何网络元素,所以我们得到了NoneType

Please put some delays or hardcoded sleep before interaction like time.sleep(5) to see if that helps.请在诸如time.sleep(5)类的交互之前放置一些延迟或硬编码睡眠,以查看是否有帮助。

c:/Users/u117235/Desktop/SecureCRT/Script/New_project/demontage.py c:/Users/u117235/Desktop/SecureCRT/Script/New_project/demontage.py:15: DeprecationWarning: use options instead of chrome_options browser = webdriver.Chrome(executable_path=r"C:\\Users\ᅲ35\\Desktop\\SecureCRT\\Script\\chromedriver.exe", chrome_options=options) c:/Users/u117235/Desktop/SecureCRT/Script/New_project/demontage.py c:/Users/u117235/Desktop/SecureCRT/Script/New_project/demontage.py:15: DeprecationWarning: 使用 options 而不是 chrome_options browser = webdriver。 Chrome(executable_path=r"C:\\Users\ᅲ35\\Desktop\\SecureCRT\\Script\\chromedriver.exe", chrome_options=options)

DevTools listening on ws://127.0.0.1:57240/devtools/browser/d323648f-3645-4af8-9623-5ac18c2d6cab Traceback (most recent call last): File "c:/Users/u117235/Desktop/SecureCRT/Script/New_project/demontage.py", line 99, in WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="pvBody_PageTemplate_innerHolder_ctrlLogon_btnLogon"]'))).click() File "C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\selenium\\webdriver\\support\\wait.py", line 71, in until value = method(self._driver) File "C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\selenium\\webdriver\\support\\expected_conditions.py", line 297, in call element = visibility_of_element_located(self.locator)(driver) File "C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\selenium\\webdriver\\support\\expected_conditions.py", line 128, in call return _element_if_visible(_find_element(driver, self.locator)) File "C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\selenium\\webdriver\\support\\expected_conditions.py", line 148, in _element_if_visi DevTools 监听 ws://127.0.0.1:57240/devtools/browser/d323648f-3645-4af8-9623-5ac18c2d6cab Traceback(最近一次调用):文件“c:/Users/u117235/RT/Desktop/SecureC /demontage.py”,第 99 行,在 WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="pvBody_PageTemplate_innerHolder_ctrlLogon_btnLogon"]'))).click() 文件“ C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\selenium\\webdriver\\support\\wait.py”,第 71 行,in until value = method(self._driver) 文件“C:\\Users\ᅲ35\\Anaconda3\\ lib\\site-packages\\selenium\\webdriver\\support\\expected_conditions.py”,第 297 行,调用element = visible_of_element_located(self.locator)(driver) 文件“C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\ selenium\\webdriver\\support\\expected_conditions.py”,第 128 行,调用return _element_if_visible(_find_element(driver, self.locator)) 文件“C:\\Users\ᅲ35\\Anaconda3\\lib\\site-packages\\selenium\\webdriver\\support \\expected_conditions.py”,第 148 行,在 _element_if_visi ble return element if element.is_displayed() == visibility else False AttributeError: 'NoneType' object has no attribute 'is_displayed' ble 返回元素 if element.is_displayed() ==可见性 else False AttributeError: 'NoneType' 对象没有属性 'is_displayed'

(base) C:\\Users\ᅲ35\\Desktop\\SecureCRT\\Script>[17072:19628:1021/102736.218:ERROR:chrome_browser_main_extra_parts_metrics.cc(228)] crbug.com/1216328: Checking Bluetooth availability started. (base) C:\\Users\ᅲ35\\Desktop\\SecureCRT\\Script>[17072:19628:1021/102736.218:ERROR:chrome_browser_main_extra_parts_metrics.cc(228)] crbug.com/1216328:开始检查蓝牙可用性Please report if there is no report that this ends.如果没有报告结束,请报告。 [17072:17148:1021/102736.222:ERROR:device_event_log_impl.cc(214)] [10:27:36.223] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: Un pÚriphÚrique attachÚ au systÞme ne fonctionne pas correctement. [17072:17148:1021/102736.222:ERROR:device_event_log_impl.cc(214)] [10:27:36.223] USB: usb_device_handle_win.cc:1048 无法从节点连接读取:Un pÚriphementÚtneattachmentÚtneattachmentÚrique (0x1F) [17072:19628:1021/102736.234:ERROR:chrome_browser_main_extra_parts_metrics.cc(231)] crbug.com/1216328: Checking Bluetooth availability ended. (0x1F) [17072:19628:1021/102736.234:ERROR:chrome_browser_main_extra_parts_metrics.cc(231)] crbug.com/1216328:检查蓝牙可用性结束。 [17072:19628:1021/102736.237:ERROR:chrome_browser_main_extra_parts_metrics.cc(234)] crbug.com/1216328: Checking default browser status started. [17072:19628:1021/102736.237:ERROR:chrome_browser_main_extra_parts_metrics.cc(234)] crbug.com/1216328:开始检查默认浏览器状态。 Please report if there is no report that this ends.如果没有报告结束,请报告。 [17072:19628:1021/102736.247:ERROR:chrome_browser_main_extra_parts_metrics.cc(238)] crbug.com/1216328: Checking default browser status ended. [17072:19628:1021/102736.247:ERROR:chrome_browser_main_extra_parts_metrics.cc(238)] crbug.com/1216328:检查默认浏览器状态已结束。 [17072:17148:1021/102736.261:ERROR:device_event_log_impl.cc(214)] [10:27:36.261] Bluetooth: bluetooth_adapter_winrt.cc:1204 Getting Radio failed. [17072:17148:1021/102736.261:ERROR:device_event_log_impl.cc(214)] [10:27:36.261] 蓝牙:bluetooth_adapter_winrt.cc:1204 获取无线电失败。 Chrome will be unable to change the power state by itself. Chrome 将无法自行更改电源状态。 [17072:17148:1021/102736.290:ERROR:device_event_log_impl.cc(214)] [10:27:36.291] Bluetooth: bluetooth_adapter_winrt.cc:1297 OnPoweredRadiosEnumerated(), Number of Powered Radios: 0 [17072:17148:1021/102736.290:ERROR:device_event_log_impl.cc(214)] [10:27:36.291] 蓝牙:bluetooth_adapter_winrt.cc:1297 OnPoweredRadiosEnumerated(),有源无线电数量

I found it the solution I change this :我找到了我改变这个的解决方案:

browser.switch_to.window(browser.window_handles[-1])

by经过

browser.switch_to.window(browser.window_handles[1])

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

相关问题 如何使用 python selenium 登录? - How can I login using python selenium? 如何在Selenium python中按execute_script按ENTER? - How can I press ENTER by execute_script in selenium python? 如何按Selenium Python中的Enter键? - how to press enter in selenium python? 我如何简化我的代码(Python 登录系统)? - How can i sipmlify my code(Python login system)? 如何使用Python和Selenium自动登录据说不可见的元素? - How can I use Python and Selenium to auto login an element that is said to be not visible? 如何向我的 Python 端口扫描器添加提示,要求用户输入他们想要扫描的端口? - How can I add a prompt to my Python port scanner that asks users to enter what ports they want scanned? 我们如何通过硒python在文本区域中按Enter键? (另一种提交方式) - How we can press Enter button in text-area by selenium python? (another way for submission) 如何通过使用python按下按钮将数据输入数据库? - How can I enter data into database by pressing the button with using python? 如何绑定在python中按下按钮并按下Enter键? - How can I bind pressing a button and hitting an enter key in python? 我如何在 selenium fireFox Python 上更改我在同一个国家/地区的位置? - How i can change my location in same country on selenium fireFox Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM