kittudk
kittudk

Reputation: 55

Configuring PhantomjsDriver to run selenium test cases

Am new to this PhantomjsDriver in selenium webdriver.I need to run my selenium scripts in server without GUI. Please can anybody tell me how to achieve this. I need a head's up from the start of how to configure Phantomjs Driver,usage in server and rest.Below is my selenium code which i run through GUI , now i have to run these cases in server without GUI. What modifications i have to do so hat i can achieve the above task.

  public static void main(String[] args) throws IOException{

        login =args[0];
        user = args[1];
        pwd = args[2];
        TestListenerAdapter tla = new TestListenerAdapter();
        TestNG testng = new TestNG();
        testng.setOutputDirectory(args[3]);
        testng.setTestClasses(new Class[] {

            CreateMultiRecordTest.class, UpdateMultiRecordTest.class,
            DeleteMultiRecordTest.class

            });
        testng.addListener(tla);
        testng.run();

Upvotes: 1

Views: 1403

Answers (2)

Alex
Alex

Reputation: 1

This worked for me:

DesiredCapabilities dCaps = new DesiredCapabilities();
dCaps.setJavascriptEnabled(true);
dCaps.setCapability("takesScreenshot", false);
dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"C:\\phantomjs-1.9.7-windows\\phantomjs.exe");
PhantomJSDriver driver = new PhantomJSDriver(dCaps);

...

Upvotes: 0

kittudk
kittudk

Reputation: 55

Finally after a weeks time i found a solution to configure PhantomJs for my framework.Here's the solution.

DesiredCapabilities cap = new DesiredCapabilities();
java.io.File f = new java.io.File("");
String path = f.getAbsolutePath()+"\\ghostdriver-master\\src\\main.js";
cap.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY,path);
driver = new PhantomJSDriver(cap); 

Upvotes: 1

Related Questions