相关疑难解决方法(0)

在PATH中找不到firefox二进制文件.确保安装了firefox

在Selenium Grid中我试图执行一个简单的程序,Cannot find firefox binary in PATH虽然我已经在我的代码中添加了二进制路径.
我的代码和错误如下.请帮忙.提前致谢.



package Sample;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class sample1 {
     WebDriver driver;
     String  BaseURL,NodeURL;
@BeforeTest
  public void beforeTest() throws MalformedURLException {
     BaseURL="www.google.com";
     NodeURL="http://192.168.10.162:5566/wd/hub";
     DesiredCapabilities capa =DesiredCapabilities.firefox();
     capa.setBrowserName("firefox");
     capa.setCapability("binary", "C:\\Users\\praveenraj.d\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
     capa.setPlatform(Platform.ANY);
     driver=new RemoteWebDriver(new URL(NodeURL),capa);
  }
   @Test
  public void f() throws InterruptedException {
      driver.get(BaseURL);
      System.out.println(driver.getTitle());
      Thread.sleep(50000);
  }
  @AfterTest
  public void afterTest() {
      driver.quit();
  }
 }
Run Code Online (Sandbox Code Playgroud)


错误 …

java selenium selenium-grid selenium-webdriver

30
推荐指数
6
解决办法
14万
查看次数

SessionNotCreatedException:消息:预期的浏览器二进制位置,但无法在默认位置找到二进制文件,没有“moz:firefoxOptions.binary”

当我尝试在 Selenium 中创建 Firefox 实例时,出现以下错误:

Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line 
Run Code Online (Sandbox Code Playgroud)

我在 Ubuntu 20.04 上运行
任何建议将不胜感激。

browser = webdriver.Firefox()

Traceback (most recent call last):
  File "key.py", line 10, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__
    RemoteWebDriver.__init__(
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", …
Run Code Online (Sandbox Code Playgroud)

python firefox selenium selenium-webdriver geckodriver

7
推荐指数
2
解决办法
1万
查看次数

预期的浏览器二进制位置,但无法在默认位置找到二进制文件,没有使用 GeckoDriver 提供的“moz:firefoxOptions.binary”功能

from selenium import webdriver;
browser= webdriver.Firefox();
browser.get('http://www.seleniumhq.org');
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时,它给了我一个error message

Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line.
Run Code Online (Sandbox Code Playgroud)

任何想法 - 高度赞赏!

python firefox selenium selenium-webdriver geckodriver

6
推荐指数
3
解决办法
2万
查看次数

geckodriver 的 Google Colaboratory 中的 executable_path 是什么?

我想在带有 Selenium Python 包的 Google Colaboratory 中使用 geckodriver。这是我尝试过的(我不是 Ubuntu 专家)

!pip install selenium
!apt-get update 
!apt install firefox-geckodriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions

firefox_options = FirefoxOptions()
firefox_options.add_argument("--headless")
driver = webdriver.Firefox(executable_path=r'/usr/bin/firefox', options=firefox_options)
Run Code Online (Sandbox Code Playgroud)

这里r'/usr/bin/firefox是错误的。我糊涂了。解决办法是什么?任何帮助表示赞赏。

firefox python-3.x selenium-webdriver geckodriver google-colaboratory

5
推荐指数
1
解决办法
2842
查看次数