Question

Quelqu'un peut-il me dire comment commencer à tester avec PhantomJS ?J'ai téléchargé le fichier exe PhantomJS et défini également ma variable "path".

Et je fais quelque chose de similaire pour Chrome comme

if(config.getProperty("browser").equals("chrome")) { System.setProperty("webdriver.chrome.driver", "C:drivers\\chromedriver.exe"); driver= new ChromeDriver(); }

lequel est

if(config.getProperty("browser").equals("phantom"))
    {
        System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe");
        driver= new PhantomJSDriver();
    }

Mais cela ne fonctionne pas.S'il vous plaît, aidez-moi.Je ne souhaite pas utiliser RemoteWebDriver ou GhostDriver

Était-ce utile?

La solution

J'ai compris :

if(config.getProperty("browser").equals("phantom"))
{
    System.setProperty("phantomjs.binary.path", "C:\\drivers\\chromedriver.exe");
    driver= new PhantomJSDriver();
}

Autres conseils

PhantomJSDriver accepte le chemin vers l'exécutable comme argument du constructeur :

if (config.getProperty("browser").equals("phantom"))
    driver= new PhantomJSDriver("C:\\drivers\\chromedriver.exe");

Recherchez le code phantomjs ci-dessous et définissez la clé et la valeur de la propriété :

//System.setProperty("phantomjs.binary.path","phantomjs.exe path");


System.setProperty("phantomjs.binary.path", System.getProperty("user.dir")+"/ExternalLibraryFiles/phantomjs-2.1.1-windows/phantomjs-2.1.1-windows/bin/phantomjs.exe");

driver =new PhantomJSDriver();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top