2017-02-28 30 views
0

Ich habe ein Jar mit einem relativen Pfad erstellt (bedeutet, ich habe den Geckodriver in den Ressourcen gegeben und zugeordnet), aber das Problem ist Firefox startet, aber URL wird nicht geladen. Ich benötige es für mehrere Systeme mit mehreren Betriebssystemen. Kann jemand helfen?URL wird nicht geladen in Firefox (Selen)

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"); 
+0

Funktioniert es mit anderen Browsern? – balazs630

+0

nein. URL lädt in keinem Browser –

+0

Bitte schauen Sie sich den obigen Code an. Es funktioniert auf der Maschine ich entwickelte das Skript auf, aber nicht auf anderen Computer mit Firefox 49 und höher. Verwenden Sie eine JAR-Datei, um es auszuführen. –

Antwort

0

Bekanntes Problem tritt auf, wenn es Sie niedrigere Version verwenden geckodriver, Eine weitere hinzuzufügen, um die Gecko-Treiberversion zu überprüfen ist kompatibel oder nicht mit Ihrer bestimmten Umgebung. Sie können die neueste Version von https://github.com/mozilla/geckodriver/releases herunterladen

+0

Ich benutze die neueste .. –

+0

Können Sie weitere Details über Ihre Umgebung – Abhishek

+0

intellij 16.3, Gecko v0.14.0. fähig, es bis FF 48 Version zu laufen. Es ist eine komplette Website mit Selen und Java automatisiert. FF 49,50 und 51 funktioniert nicht. Ich brauche es, um es auf verschiedenen Rechnern laufen zu lassen, auf denen verschiedene Versionen von OS und Firefox laufen. –

Verwandte Themen