Selenium与Java一起使用时出现问题,使用webdriver.firefox.marionette。

huangapple go评论72阅读模式
英文:

Selenium with java issue using webdriver.firefox.marionette

问题

package main_files;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class main_downloader {
    public static void main(String[] args) throws Exception {
        System.setProperty("webdriver.firefox.marionette", "C:\\Users\\ahmed\\Desktop\\JavaPackage\\packages\\webdriver\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.wait(1);
        driver.get("https://www.google.com/");
        driver.quit();
    }
}

不清楚为什么,但出于某种原因这不起作用!当我尝试运行它时,它只是打开一个 Firefox 窗口然后什么都不做!甚至搜索栏 "本应识别出我在使用机器人并更改其主题" 也没有做到这一点。有人可以告诉我到底是什么问题吗?谢谢。

英文:
package main_files;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class main_downloader {
	public static void main(String[] args) throws Exception {
		System.setProperty("webdriver.firefox.marionette", "C:\\Users\\ahmed\\Desktop\\JavaPackage\\packages\\webdriver\\geckodriver.exe");
		WebDriver driver = new FirefoxDriver();
		driver.wait(1);
		driver.get("https://www.google.com/");
		driver.quit();
	}
}

idk why, but for some reason this not working !, when I try to run it it just opens a Firefox window and do nothing !, even the search bar "which is supposed to recognize that I'm using a bot and change it's theme" is not doing that, could anyone tell me what's the exact problem please?!, Thx

答案1

得分: 1

当前的Selenium实现不再使用键webdriver.firefox.marionette,而是需要使用webdriver.gecko.driver。实际上,您需要将以下代码行:

System.setProperty("webdriver.firefox.marionette", "C:\\Users\\ahmed\\Desktop\\JavaPackage\\packages\\webdriver\\geckodriver.exe");

替换为:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\ahmed\\Desktop\\JavaPackage\\packages\\webdriver\\geckodriver.exe");

参考资料

您可以在以下讨论中找到一些相关的详细信息:

英文:

The current implementation of Selenium no more uses the key webdriver.firefox.marionette and instead of that you need to use webdriver.gecko.driver. Effectively, you need to replace the line:

System.setProperty("webdriver.firefox.marionette", "C:\\Users\\ahmed\\Desktop\\JavaPackage\\packages\\webdriver\\geckodriver.exe");

with:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\ahmed\\Desktop\\JavaPackage\\packages\\webdriver\\geckodriver.exe");

References

You can find a couple of relevent detailed discussions in:

huangapple
  • 本文由 发表于 2020年8月15日 05:54:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63420450.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定