Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未在Firefox中加载URL(Selenium)_Selenium_Selenium Webdriver_Selenium Ide_Geckodriver - Fatal编程技术网

未在Firefox中加载URL(Selenium)

未在Firefox中加载URL(Selenium),selenium,selenium-webdriver,selenium-ide,geckodriver,Selenium,Selenium Webdriver,Selenium Ide,Geckodriver,我创建了一个带有相对路径的jar(意味着我在资源中给出了geckodriver并对其进行了映射),但问题是firefox启动了,但url没有加载。我需要它在运行多个操作系统的多个系统上运行。有人能帮忙吗 import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.ExtentTest; import com.relevantcodes.extentreports.LogS

我创建了一个带有相对路径的jar(意味着我在资源中给出了geckodriver并对其进行了映射),但问题是firefox启动了,但url没有加载。我需要它在运行多个操作系统的多个系统上运行。有人能帮忙吗

import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import org.junit.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.BeforeTest;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


public class Maintest {

    public static FirefoxDriver driver;
    //public static ChromeDriver driver;
    public static String downloadPath = "/home/user/Desktop/Downloads";
    private static ExtentReports reports;


    @BeforeTest

    public static void createDriver() {
        System.setProperty("webdriver.firefox.marionette", "/home/user/Desktop/geckodriver");
        driver = new FirefoxDriver(FirefoxDriverProfile());
        driver.manage().window().maximize();
    }

    public static FirefoxProfile FirefoxDriverProfile() {
        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("browser.download.folderList", 2);
        profile.setPreference("browser.download.manager.showWhenStarting", false);
        profile.setPreference("browser.download.dir", downloadPath);
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream");
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv, application/pdf,application/octet-stream");
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,application/x-pdf, application/pdf,application/vnd.fdf,application/vnd.ppdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf, application/foxit");
        profile.setPreference("browser.helperApps.neverAsk.openFile",
                "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml/application/pdf");
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml/application/pdf");
        profile.setPreference("browser.helperApps.alwaysAsk.force", false);
        profile.setPreference("pdfjs.disabled", true);
        profile.setPreference("plugin.scan.Acrobat", "99.0");
        profile.setPreference("plugin.scan.plid.all", false);
        profile.setPreference("plugin.disable_full_page_plugin_for_types", "application/pdf");
        profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
        profile.setPreference("browser.download.manager.focusWhenStarting", false);
        profile.setPreference("browser.download.manager.useWindow", false);
        profile.setPreference("browser.download.manager.showAlertOnComplete", false);
        profile.setPreference("browser.download.manager.closeWhenDone", false);
        return profile;
    }

    @Test

    public static void bridge(List<String> selectedList) throws Exception {
        createDriver();
        System.out.println("###############"+new Date()+"###############\n\n");
        DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
        Date date = new Date();
        String dateTime = format.format(date);
        reports = new ExtentReports("/home/user/Desktop/Regression Results-"+dateTime+".html", true);
       driver.get("http://sitename");
import com.relevantcodes.extentreports.extentreports;
导入com.relevantcodes.extentreports.extendettest;
导入com.relevantcodes.extentreports.LogStatus;
导入org.junit.Test;
导入org.openqa.selenium.firefox.FirefoxDriver;
导入org.openqa.selenium.firefox.FirefoxProfile;
导入org.testng.annotations.BeforeTest;
导入java.text.DateFormat;
导入java.text.simpleDataFormat;
导入java.util.Date;
导入java.util.List;
公共类测试{
公共静态Firefox驱动程序;
//公共静态色度驱动器;
公共静态字符串downloadPath=“/home/user/Desktop/Downloads”;
私有静态扩展报告;
@试验前
公共静态void createDriver(){
System.setProperty(“webdriver.firefox.marionete”,“/home/user/Desktop/geckodriver”);
驱动程序=新的FirefoxDriver(FirefoxDriverProfile());
driver.manage().window().maximize();
}
公共静态FirefoxProfile FirefoxDriverProfile(){
FirefoxProfile profile=新的FirefoxProfile();
profile.setPreference(“browser.download.folderList”,2);
profile.setPreference(“browser.download.manager.showWhenStarting”,false);
profile.setPreference(“browser.download.dir”,downloadPath);
setPreference(“browser.helperApps.neverAsk.saveToDisk”,“应用程序/八位字节流”);
setPreference(“browser.helperApps.neverAsk.saveToDisk”、“text/csv、application/pdf、application/octet-stream”);
profile.setPreference(“browser.helperApps.neverAsk.saveToDisk”、“application/pdf、application/x-pdf、application/pdf、application/vnd.fdf、application/vnd.ppdf、application/acrobat、applications/vnd.pdf、text/x-pdf、application/vnd.cups-pdf、application/foxit”);
profile.setPreference(“browser.helperApps.neverAsk.openFile”,
“text/csv、application/x-msexcel、application/excel、application/x-excel、application/vnd.ms excel、image/png、image/jpeg、text/html、text/plain、application/msword、application/xml/application/pdf”);
profile.setPreference(“browser.helperApps.neverAsk.saveToDisk”,
“text/csv、application/x-msexcel、application/excel、application/x-excel、application/vnd.ms excel、image/png、image/jpeg、text/html、text/plain、application/msword、application/xml/application/pdf”);
profile.setPreference(“browser.helperApps.alwaysAsk.force”,false);
setPreference(“pdfjs.disabled”,true);
setPreference(“plugin.scan.Acrobat”,“99.0”);
setPreference(“plugin.scan.plid.all”,false);
profile.setPreference(“plugin.disable_full_page_plugin_for_type”,“application/pdf”);
setPreference(“browser.download.manager.alertOnEXEOpen”,false);
profile.setPreference(“browser.download.manager.focuswhen启动”,false);
setPreference(“browser.download.manager.useWindow”,false);
profile.setPreference(“browser.download.manager.showartoncomplete”,false);
profile.setPreference(“browser.download.manager.closeWhenDone”,false);
回报曲线;
}
@试验
公共静态无效桥(List selectedList)引发异常{
createDriver();
系统.输出.打印(“[新日期]+[新日期])”;
DateFormat格式=新的SimpleDateFormat(“dd-MM-yyyy”);
日期=新日期();
字符串dateTime=format.format(日期);
报告=新的扩展报告(“/home/user/Desktop/Regression Results-”+dateTime+“.html”,true);
驱动程序。获取(“http://sitename");

已知问题—当您使用geckodriver较低版本时,会出现此问题,请再添加一个以检查gecko驱动程序版本是否与给定环境兼容。
您可以从

下载最新版本,它是否适用于其他浏览器?否。url不会加载到任何浏览器中。请查看上面的代码。它适用于我开发脚本的机器,但不适用于firefox 49或更高版本的其他机器。使用jar文件运行它。您能否提供有关您的环境Intellij16.3的更多详细信息,gecko v0.14.0。能够运行到FF 48版本。这是一个使用selenium和java自动化的整个站点。FF 49,50和51不工作。我需要它在运行不同操作系统和firefox版本的不同机器上运行。使用最新的selenium 3.1.0,FF 49,50中最新的gecko v0.14.0,来运行脚本,您必须使用最新的selenium,gecko版本下载最新的selenium和gecko时,请检查FF版本50,51,52。我通过intellij在所有版本上都可以使用它,但当我制作一个罐子并将其复制到其他机器上时,它就不起作用了。