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
1,998 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 16, 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
16,289 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,140 points
1,762 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,500 points
13,776 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,190 points
9,190 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,910 points
7,267 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 3, 2020 in Selenium by Sri
• 3,190 points
7,904 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
1,127 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
33,767 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP