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
633 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,150 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
11,980 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
• 28,040 points
640 views
0 votes
2 answers

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,520 points
5,092 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
5,827 views
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,890 points
3,596 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,010 points
4,337 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,150 points
209 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,150 points
27,043 views