当前位置: 首页 > 知识库问答 >
问题:

在python中使用selenium创建gmail登录bot时出现蓝牙错误。但即使是对“Email”id元素的基本搜索也找不到

姬墨竹
2023-03-14

它似乎不起作用,并不断给我一个关于蓝牙驱动程序的错误,以下是我的代码:-

from selenium import webdriver
from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

usernameStr = 'putYourUsernameHere'
passwordStr = 'putYourPasswordHere'

browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/ServiceLogin?'
            'service=mail&continue=https://mail.google'
            '.com/mail/#identifier'))

# fill in username and hit the next button

username = browser.find_element_by_id('Email')
username.send_keys(usernameStr)

nextButton = browser.find_element_by_id('next')
nextButton.click()

# wait for transition then continue to fill items

password = WebDriverWait(browser, 10).until(
    EC.presence_of_element_located((By.ID, "Passwd")))

password.send_keys(passwordStr)

signInButton = browser.find_element_by_id('signIn')
signInButton.click()

这是我的代码的错误:-

[11092:17164:0603/171812.746:错误:设备\u事件\u日志\u执行cc(208)][17:18:12.747]蓝牙:蓝牙适配器\u winrt.cc:723 GetBluetoothAdapterStaticActivationFactory失败:未注册类(0x80040154)

Traceback(最近一次调用最后一次):文件"e:/python.py",第62行,用户名=browser.find_element_by_id('电子邮件')文件"C:\用户\Bhaskar\AppData\本地\程序\Python\Python37\lib\site-包\selenium\web驱动\远程\webdriver.py",行360,find_element_by_id返回self.find_element(by=By.ID, value=id_)文件"C:\用户\Bhaskar\AppData\本地\程序\Python\Python37\lib\site-包\selenium\webDrive\远程\webdriver.py",第978行,find_element'value': value})['value']文件"C:\用户\Bhaskar\AppData\本地\程序\Python\Python37\lib\site-包执行self.error_handler.check_response(响应)File"C:\用户\Bhaskar\AppData\本地\程序\Python\Python37\lib\site-包\selenium\webDrive\远程\errorhandler.py",第242行,check_response升起exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.NoSuchElementExcture:消息:没有这样的元素:无法定位元素:{"方法":"css选择器","选择器":"[id="电子邮件"]"}(会话信息: chrome=83.0.4103.61)

共有3个答案

公西俊才
2023-03-14

您要查找的ID是“identifierId”。试试这个。

申颖逸
2023-03-14

用户名框的id不是“Email”,而是“identifierId”。“下一步”按钮也是如此。

试试这样(可能对你有点不同,因为我有不同语言的谷歌)。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

usernameStr = 'putYourUsernameHere'
passwordStr = 'putYourPasswordHere'

browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/ServiceLogin?'
            'service=mail&continue=https://mail.google'
            '.com/mail/#identifier'))

# fill in username and hit the next button

username = browser.find_element_by_id('identifierId')
username.send_keys(usernameStr)

nextButton = browser.find_element_by_xpath('//*[@id="identifierNext"]/span/span')
nextButton.click()

在此之后,谷歌阻止了我的尝试。。。

孙昂然
2023-03-14

更详细地解释您的问题,包括错误消息或一组代码或屏幕截图。

 类似资料:
  • 这是我写的,这是一个简单的程序,可以登录我的instagram帐户,凭证已更改: 我不知道它为什么会出错。请帮忙。 Chrome确实打开了登录页面,但找不到元素。 附言:你可以猜到我是新来的 编辑: 我想,当我使用time.sleep几秒钟,它正常工作......但我不认为这是修复它的最佳方式,所以请注意,并建议我一些东西,或者这是它实际上是如何工作的......

  • 问题内容: 我正在尝试使用Selenium登录gmail。在新的gmail登录中,首先输入您的电子邮件ID,然后在下一页输入密码。电子邮件页面的URL和密码页面的URL不同。因此,当我在其中传递密码URL时,它将重新加载页面,并且如果您刷新URL而未输入密码,它将重定向到电子邮件页面。因此,它缺少密码字段选择器。仍然是先前的网址,即电子邮件页面的网址。这是我的代码。我正在使用Chrome驱动程序和

  • 我做了一个代码,尝试登录我的instagram账户,但它给了我很多错误。我怎样才能修好它们? 代码: 错误: 警告(来自警告模块):文件“C:\users\usuario\appdata\local\programs\python\python37\lib\site-packages\Selenium\webdriver\PhantomJS\webdriver.py”,第49行warnings.w

  • 请参考截图。我正试图单击“取消”按钮,如我的截图所示。即使元素的ID存在,我也无法单击按钮。弹出窗口既不是一个新窗口,也不像是一个警告我。我试图搜索是否是窗口句柄的问题。但是当我搜索窗口句柄时,它只给我一个数字: 收到错误消息- 线程“main”org.openqa.selenium.nosuchelementexception:没有这样的元素:找不到元素:{“method”:“id”,“sele

  • 这里有两个代码段,我正在使用它们从具有“From Date”和“To Date”的日历中搜索日期。 错误消息显示:线程“main”组织中出现异常。openqa。硒。NoSuchElementException:没有这样的元素:无法定位元素:{“method”:“xpath”,“selector”:“//table/tbody/tr/a[包含(text(),'十月三十日')]”“}

  • 查找元素的函数如下所示: 每次需要查找元素时,我都会调用这个函数。 有一个特定的有问题的按钮,有时工作,有时不工作。它给出了一个错误:selenium.common.exceptions。元素点击拦截异常:消息:元素点击拦截:元素…在点(840,12)处不可点击。其他元素将收到点击: 问题是有时它工作(当我使用更大的显示器时)有时它不工作,当我运行调试器时,等待几秒钟10/20,然后它变得可点击。