我正在关注 python 文档,终端向我抛出回溯错误,浏览器也启动并退出,即使我没有一行

问题描述 投票:0回答:1
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service

website = 'https://www.saucedemo.com'
path =  "/Users/Bernardo Cabrera/PycharmProjects/Project/resource/msedgedriver.exe"

  options = webdriver.EdgeOptions()
  options.add_experimental_option("Detach", True)

  service = Service(executable_path=path)
  driver = webdriver.Edge(service=service)
  driver.get(website)
  driver.maximize_window()

  username= driver.find_element(By.ID, 'loginForm')
  password= driver.find_element(By.ID, "password")
  loginButton= driver.find_element(By.ID, "login-button")
  FailedLogin= driver.find_element(By.CLASS_NAME, "svg-inline--fa fa-times-circle fa-w-16 fa-2x ")

      username.send_keys("usersaucename")
      password.send_keys("superdemosauce")
      loginButton.click()
      assert FailedLogin.is_displayed()
python selenium-webdriver automation-testing
1个回答
0
投票

@迈克尔·布彻 这是日志 回溯(最近一次调用最后一次): 文件“C:\Users\Bernardo Cabrera\PycharmProjects\Project\News.py”,第 18 行,位于 用户名= driver.find_element(By.ID, 'loginForm') 文件“C:\Users\Bernardo Cabrera\PycharmProjects\Project env\lib\site-packages\selenium\webdriver emote\webdriver.py”,第 748 行,在 find_element 中 return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] 文件“C:\Users\Bernardo Cabrera\PycharmProjects\Project env\lib\site-packages\selenium\webdriver emote\webdriver.py”,第 354 行,执行中 self.error_handler.check_response(响应) 文件“C:\Users\Bernardo Cabrera\PycharmProjects\Project env\lib\site-packages\selenium\webdriver emote rrorhandler.py”,第 229 行,在 check_response 中 引发异常类(消息、屏幕、堆栈跟踪) selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{“method”:“css选择器”,“selector”:“[id =“loginForm”]”} (会话信息:MicrosoftEdge=126.0.2592.102);有关此错误的文档,请访问:https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception 堆栈跟踪: GetHandleVerifier [0x00007FF605F48132+13538] 微软::应用程序::事件::EventProperty::~EventProperty [0x00007FF605ED1DE9+595465] (无符号)[0x00007FF605CEE6CF] (无符号)[0x00007FF605D32960] (无符号)[0x00007FF605D32A1F] (无符号)[0x00007FF605D6D627] (无符号)[0x00007FF605D5203F] (无符号)[0x00007FF605D28147] (无符号)[0x00007FF605D6B1EE] (无符号)[0x00007FF605D51C63] (无符号)[0x00007FF605D2766E] (无符号)[0x00007FF605D2683C] (无符号)[0x00007FF605D27221] 微软::应用程序::事件::EventProperty::to_string [0x00007FF6061096D4+1099860] Microsoft::应用程序::事件::EventProperty::~EventProperty [0x00007FF605E4D8FC+53532] 微软::应用程序::事件::EventProperty::~EventProperty [0x00007FF605E40E25+1605] 微软::应用程序::事件::EventProperty::to_string [0x00007FF606108665+1095653] 微软::应用程序::事件::ILogConfiguration::运算符* [0x00007FF605EDC961+27777] Microsoft::应用程序::事件::ILogConfiguration::运算符* [0x00007FF605ED6CE4+4100] Microsoft::应用程序::事件::ILogConfiguration::运算符* [0x00007FF605ED6E1B+4411] 微软::应用程序::事件::EventProperty::~EventProperty [0x00007FF605ECCFA0+575424] BaseThreadInitThunk [0x00007FFE4A75257D+29] RtlUserThreadStart [0x00007FFE4C1AAF28+40]

© www.soinside.com 2019 - 2024. All rights reserved.