无法使用给定的 URL 打开 Firefox 浏览器 - Selenium Webdriver & Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34513547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to open Firefox browser with given URL - Selenium Webdriver & Java
提问by Karunagara
I have written the following selenium script which opens Gmail website.
我编写了以下打开 Gmail 网站的 selenium 脚本。
import org.openqa.selenium.WebDriver; <br>
import org.openqa.selenium.firefox.*;
public class OpenGmail {
/**
* @param args
*/
public void OpenGmailApp()
{
WebDriver webdriver = new FirefoxDriver();
webdriver.get("gmail URL");
}
public static void main(String[] args) {
OpenGmail ob = new OpenGmail();
ob.OpenGmailApp();
}
}
When I execute the above script, I'm getting Firefox home page only. Its not gmail login page. Kindly guide what could be the error I made in that script.
当我执行上述脚本时,我只获得了 Firefox 主页。它不是 gmail 登录页面。请指导我在该脚本中犯的错误。
采纳答案by VinG
I have faced the same problem. Now issue is fixed. download the latest selenium jar and replace the external jar of project in eclipse. Check the selenium jars. Selenium supports Firefox so it directly initiate the instance of Firefox WebDriver, but due to selenium jars compatibility url id not opening.
我遇到了同样的问题。现在问题已解决。下载最新的selenium jar,替换eclipse中project的外部jar。检查硒罐。Selenium 支持 Firefox,因此它直接启动 Firefox WebDriver 的实例,但由于 selenium jars 兼容性 url id 未打开。
回答by Arsalan
If your jar files are old and the browser was updated to latest version, then download the latest jar files from selenium website -
如果你的 jar 文件是旧的并且浏览器更新到最新版本,那么从 selenium 网站下载最新的 jar 文件 -
You can also use the Selenium FF addon..
您还可以使用 Selenium FF 插件。
All the steps can be recorded in the addon and the script can be exported.
所有步骤都可以记录在插件中,并且可以导出脚本。
回答by Shubham Jain
This is due to the unsigned .xpi (selenium 2.45.0) not being loaded by firefox 43. It's a temporary fix. Selenium will be going to update their jar soon after this you will not need to use this profiling
这是由于 firefox 43 未加载未签名的 .xpi(selenium 2.45.0)。这是一个临时修复。在此之后,Selenium 将很快更新他们的 jar,您将不需要使用此分析
Full Code:-
完整代码:-
public void OpenGmailApp()
{
WebDriver driver = null;
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.co.in/");
}
public static void main(String[] args) {
OpenGmail ob = new OpenGmail();
ob.OpenGmailApp();
}
Another thing which can cause issue is either old selenium jars or old browser version. So update both of them.
可能导致问题的另一件事是旧的 selenium jar 或旧的浏览器版本。所以更新他们两个。
Download latest jars from below URL:- http://www.seleniumhq.org/download/
从以下 URL 下载最新的 jars:- http://www.seleniumhq.org/download/
Hope it will help you :)
希望它会帮助你:)
回答by sathish p
If you are running via Jenkins/Command prompt then along with updating your selenium jars, delete the older version of that particular jars in your library folder. Keeping both versions might create issue while running via Jenkins/Command prompt
如果您通过 Jenkins/命令提示符运行,那么在更新硒 jar 的同时,删除库文件夹中该特定 jar 的旧版本。通过 Jenkins/命令提示符运行时保留两个版本可能会产生问题