How to launch PhantomJS driver using Desired Capability?

0 votes
How to launch PhantomJS driver using Desired Capability?
Jul 15, 2019 in Selenium by Usha
225 views

1 answer to this question.

0 votes

Hey usha, to launch PhantomJS driver using Desired Capabilities in Selenium, you can use this code snippet:

public static void main(String[] args) {

            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.setJavascriptEnabled(true);

            capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C://phantomjs.exe");

            capabilities.setCapability("takesScreenshot", true);

            WebDriver driver = new PhantomJSDriver(capabilities);

            driver.get("https://www.google.com");

            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

            String title = driver.getTitle();

            System.out.println(title);

    }
answered Jul 15, 2019 by Anvi
• 14,030 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
3 answers

How to click the search button using Selenium web driver and Python

You can try with tag. #this code will ...READ MORE

answered Apr 10, 2019 in Selenium by Matin
7,622 views
0 votes
1 answer
0 votes
1 answer

How to run test scripts in Selenium using PhantomJS?

Hey @Shushil, you can run your test ...READ MORE

answered May 17, 2019 in Selenium by Abha
• 27,920 points
250 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
2,555 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
2,028 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,870 points
2,118 views
0 votes
1 answer

How to launch browsers using Python-Selenium?

Hey Nikita, to launch browser in Python-Selenium, ...READ MORE

answered May 24, 2019 in Selenium by Anvi
• 14,030 points
87 views
0 votes
1 answer

How to extract text from a web page using selenium and save it as a text file?

Hello Isha, you can checkout this code ...READ MORE

answered May 7, 2019 in Selenium by Anvi
• 14,030 points
13,852 views