无法向字段输入电子邮件id,除此之外还可以帮助我处理这些错误。[代码错误2。
serviceC = Service(r"C:\chromedriver_win32\chromedriver.exe")
driver = webdriver.Chrome(service=serviceC)
# My gmail credentials
my_username = "my_mail_id@fake.com"
my_password = "mypassword"
# open Wev.flock.com login
driver.get("http://web.flock.com")
print("Website link")
driver.implicitly_wait(10)
# Get started With Flock
Enter_email_id = driver.find_element(By.XPATH, '//*[@id="widgets_InputBox_0"]/input')
# XPATH = '//*[@id="widgets_InputBox_0"]/input'
# Full XPATH = '/html/body/div[3]/div/div[1]/div/div/div[3]/div[3]/input'
Enter_email_id.send_keys(my_username)
# automatically close the driver after 30 seconds
time.sleep(30)
driver.close()
下面我通过终端附加输出,主要问题是我找不到合适的地址到输入字段selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{“方法”:“xpath”,"selector":"//*@id="widgets_InputBox_0"/input"}
任何帮助都会成为学徒
DevTools listening on ws://127.0.0.1:55084/devtools/browser/fa303344-68e7-4306-a7fd-511ef7d18a15
Website link
[1676:6032:0925/155230.539:ERROR:device_event_log_impl.cc(214)] [15:52:30.540] USB: usb_service_win.cc:415 Could not read device interface GUIDs: The system cannot find the file specified. (0x2)
[1676:6032:0925/155230.540:ERROR:device_event_log_impl.cc(214)] [15:52:30.540] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[1676:6032:0925/155230.541:ERROR:device_event_log_impl.cc(214)] [15:52:30.542] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Traceback (most recent call last):
File "d:\Projects\FlockAutomation.py", line 22, in <module>
Enter_email_id = driver.find_element(By.XPATH, '//*[@id="widgets_InputBox_0"]/input')
File "C:\Users\itadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 855, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\itadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "C:\Users\itadmin\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
**selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="widgets_InputBox_0"]/input"}**
(Session info: chrome=105.0.5195.127)
Stacktrace:
Backtrace:
Ordinal0 [0x007BDF13+2219795]
Ordinal0 [0x00752841+1779777]
Ordinal0 [0x0066423D+803389]
Ordinal0 [0x00693025+995365]
Ordinal0 [0x006931EB+995819]
Ordinal0 [0x006C0F52+1183570]
Ordinal0 [0x006AE844+1108036]
Ordinal0 [0x006BF192+1175954]
Ordinal0 [0x006AE616+1107478]
Ordinal0 [0x00687F89+950153]
Ordinal0 [0x00688F56+954198]
GetHandleVerifier [0x00AB2CB2+3040210]
GetHandleVerifier [0x00AA2BB4+2974420]
GetHandleVerifier [0x00856A0A+565546]
GetHandleVerifier [0x00855680+560544]
Ordinal0 [0x00759A5C+1808988]
Ordinal0 [0x0075E3A8+1827752]
Ordinal0 [0x0075E495+1827989]
Ordinal0 [0x007680A4+1867940]
BaseThreadInitThunk [0x75B46739+25]
RtlGetFullPathName_UEx [0x76FD8FD2+1218]
RtlGetFullPathName_UEx [0x76FD8F9D+1165]
发布于 2022-09-30 11:51:15
我得到了答案,很简单,只需指向iframe,然后指向要输入或单击的元素。
iframe = driver.find_element( By.XPATH,By.XPATH) driver.switch_to.frame(iframe)
从羊群开始
Enter_email_id = driver.find_element(By.XPATH,'//*@id="widgets_InputBox_0"/input') driver.implicitly_wait(5) Enter_email_id.send_keys(my_username)
Login_or_create_btn = driver.find_element( By.XPATH,‘/*@id=“uniqName_15_0”/div3 3/By.XPATH’)
Login_or_create_btn.click()
sign_in_with_google=driver.find_element(By.XPATH,‘//*@id=“uniqName_17_0”/div2 2/按钮’) sign_in_with_google.click()
发布于 2022-09-25 14:29:59
元素在iframe内部,您可以先定位iframe,我使用另一个python,只需要3行代码就可以实现这个自动化。它使用浏览器扩展,首先需要通过代码cc.chrome.extension.install_or_update()
安装扩展。
从clicknium导入clicknium作为cc,定位器,ui
选项卡= cc.chrome.open('https://web.flock.com/')
iframe = tab.find_element_by_xpath('//@id="dijit__WidgetsInTemplateMixin_0"/iframe') iframe.find_element_by_xpath('//@id="widgets_InputBox_0"/input').set_text("test")
https://stackoverflow.com/questions/73843784
复制相似问题