GVKun编程网logo

FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException(Firefox中的不安全密码警示)

8

想了解FireFox中的SeleniumOpenQA.Selenium.DriverServiceNotFoundException的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于Firef

想了解FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于Firefox中的不安全密码警示的相关问题,此外,我们还将为您介绍关于Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时、Firefox-org.openqa.selenium.interactions.MoveTargetOutOfBoundsException、from selenium.webdriver.firefox.options import Options ModuleNotFoundError: No module named 'selenium'、java – Selenium 3.0 Firefx驱动程序失败与org.openqa.selenium.SessionNotCreatedException无法创建新的远程会话的新知识。

本文目录一览:

FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException(Firefox中的不安全密码警示)

FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException(Firefox中的不安全密码警示)

我正在尝试开始编写Selenium测试,并且我编写的第一个非常基本的测试因exception失败OpenQA.Selenium.DriverServiceNotFoundException

using OpenQA.Selenium;using OpenQA.Selenium.Firefox;namespace WebDriverDemo{        class Program    {        static void Main(string[] args)        {            IWebDriver driver = new FirefoxDriver();            driver.Url = "http://www.google.com";        }    }}

调试器说我需要下载geckodriver.exe并将其设置在我的PATH变量上,这已经完成,但仍然会出现相同的异常。当我对进行相同的操作时ChromeDriver,效果很好。

同样,根据MDN,如果我使用的是Selenium
3.0或更高版本,则应默认启用它。我在Windows 10计算机上使用Selenium 3.0.1。

答案1

小编典典

您可以使用System.setProperty()方法将geckodriver位置添加到PATH中,或仅将其添加到代码中。

看看下面的链接。它显示了Java中的基本代码,您需要编写等效的C#。但是它提到了使用GeckoDriver的步骤。如果仍然无法使用,请分享您得到的错误。

http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-
geckodriver/

Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时

Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时

code is correct. added code for time out exception. implicitlyWait added
public class SeleniumClass {

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver","C:\\\\Drivers\\\\chromedriver.exe");
        //System.setProperty("webdriver.gecko.driver","F:/Selenium/Jars and Drivers/Drivers/Firefox/geckodriver-v0.29.0-win64/geckodriver.exe");
        WebDriver driver = new ChromeDriver();
        //WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
        driver.get("http://www.google.com");
    }

}
,

https://sites.google.com/a/chromium.org/chromedriver/

尝试 - 我下载了最新的稳定版本并且它有效。

Firefox-org.openqa.selenium.interactions.MoveTargetOutOfBoundsException

Firefox-org.openqa.selenium.interactions.MoveTargetOutOfBoundsException

我遇到了一个奇怪的情况,在“宁静”页面上,我必须滚动到该元素:

withAction().moveToElement(webElement).perform();

对于某些元素,此方法将抛出:

org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (377.375, 958.3999938964844) is out of bounds of viewport width (1268) and height (943)

它仅在Firefox中发生(Chrome可以正常运行)。而且,几乎所有其他我使用相同方法的地方都运行良好。所有元素只是按钮,输入字段等常用元素。

有人知道如何在Firefox中解决此问题吗?

我有:

  • Firefox 61.0.2(64位)
  • Windows 10
  • 宁静1.9.30
  • Geckodriver 0.21.0

答案1

小编典典

此错误消息…

org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (377.375, 958.3999938964844) is out of bounds of viewport width (1268) and height (943)

…暗示 Selenium 无法聚焦在所需的元素上,因为该元素超出了视口的范围。

您的主要问题是将 WebElement 标识为 webElement
不在视口中,因此 Selenium
无法通过方法将 焦点 移到所需元素上moveToElement()

一个简单的解决方案是使用executeScript()方法将所需元素 放入视口中 ,然后moveToElement()按如下所示调用方法:

WebElement myElement = driver.findElement(By.xpath("xpath_of_element"));((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", myElement);withAction().moveToElement(webElement).perform();

from selenium.webdriver.firefox.options import Options ModuleNotFoundError: No module named 'selenium'

from selenium.webdriver.firefox.options import Options ModuleNotFoundError: No module named 'selenium'

如何解决from selenium.webdriver.firefox.options import Options ModuleNotFoundError: No module named ''selenium''?

这是我的问题:当我运行 thos 脚本时,我的 cmd 向我返回一条错误消息,该消息与我的模块的导入有关。

导入脚本:

import logging
import os
import time
from lib2to3.pgen2 import driver

from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import webdriverwait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.firefox.webdriver import FirefoxProfile
from selenium.webdriver import ActionChains,DesiredCapabilities


# ================================ LOGGER ====================================
import pathlib
import platform
import shutil
import psutil

第一个 cmd 的消息是:

from selenium.webdriver.firefox.options import Options
ModuleNotFoundError: No module named ''selenium''

起初我认为这是我在安装 selenium 后安装的 FireFox 导航器的错误,但最后命令提示符给了我与 Chrome 相同的消息 :O ! 我检查了我的 Pyhton 的版本:“Python 3.9.2”。然后卸载selenium(已经安装了):

pip uninstall selenium
Found existing installation: selenium 3.141.0
Uninstalling selenium-3.141.0:
  Would remove:
    c:\users\w10cp\desktop\stage\venv\lib\site-packages\selenium-3.141.0.dist-info\*
    c:\users\w10cp\desktop\stage\venv\lib\site-packages\selenium\*
Proceed (y/n)? y
  Successfully uninstalled selenium-3.141.0

然后我再次安装它:

pip install selenium
Collecting selenium
  Using cached selenium-3.141.0-py2.py3-none-any.whl (904 kB)
Requirement already satisfied: urllib3 in c:\users\w10cp\desktop\stage\venv\lib\site-packages (from selenium) (1.26.4)
Installing collected packages: selenium
Successfully installed selenium-3.141.0

但那是一样的:

from selenium.webdriver.firefox.options import Options
ModuleNotFoundError: No module named ''selenium''

所以我跑了

C:\Users\w10cp\Desktop\Stage>python
Python 3.9.2 (tags/v3.9.2:1a79785,Feb 19 2021,13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help","copyright","credits" or "license" for more information.
>>> import selenium

但没有任何变化

File "<stdin>",line 1,in <module>
ModuleNotFoundError: No module named ''selenium''

所以我继续使用 Stack OverFlow 寻找答案。 我成功卸载了 selenium 然后执行:

python -m pip install -U selenium

所以我再次运行我的脚本,结果如​​下:

from webdriver_manager.chrome import ChromeDriverManager
ModuleNotFoundError: No module named ''webdriver_manager''

所以我做了

pip install webdriver_manager

它已成功安装,但它返回相同的错误消息。 如果有人知道我必须做什么,请帮助我。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

java – Selenium 3.0 Firefx驱动程序失败与org.openqa.selenium.SessionNotCreatedException无法创建新的远程会话

java – Selenium 3.0 Firefx驱动程序失败与org.openqa.selenium.SessionNotCreatedException无法创建新的远程会话

Selenium 3.0 Firefx驱动程序通过org.openqa.selenium.SessionNotCreatedException失败:无法创建新的远程会话.
System.setProperty("webdriver.gecko.driver","..<Path>../geckodriver.exe");
capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
driver = new FirefoxDriver(capabilities);


Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true,firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@23aa363a,browserName=firefox,moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@23aa363a,version=,platform=ANY}],required capabilities = Capabilities [{}]
Build info: version: '3.0.0',revision: '350cf60',time: '2016-10-13 10:48:57 -0700'
System info: host: 'D202540',ip: '10.22.19.193',os.name: 'Windows 7',os.arch: 'amd64',os.version: '6.1',java.version: '1.8.0_45'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:135)

解决方法

你需要下载geckodriver.然后设置
System.setProperty("webdriver.gecko.driver","path\\to\\geckodriver.exe")

检查这个link.

关于FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundExceptionFirefox中的不安全密码警示的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时、Firefox-org.openqa.selenium.interactions.MoveTargetOutOfBoundsException、from selenium.webdriver.firefox.options import Options ModuleNotFoundError: No module named 'selenium'、java – Selenium 3.0 Firefx驱动程序失败与org.openqa.selenium.SessionNotCreatedException无法创建新的远程会话的相关知识,请在本站寻找。

本文标签: