英文:
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");
参考资料
您可以在以下讨论中找到一些相关的详细信息:
- 使用“webdriver.firefox.marionette”时引起的UnreachableBrowserException和java.lang.NullPointerException
- webdriver.firefox.marionette和webdriver.gecko.driver之间的区别
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论