Vasanth Nag K V
Vasanth Nag K V

Reputation: 4988

avoid opening the browser while running selenium webDriver test cases

i have been getting a lot of help from you guys and i am really glad. have passed these huddles,

web page source downloaded through Jsoup is not equal to the actual web page source

How to download a Web page source using Selenium

and now i am finally here for the last huddle (hopefully)

while running the selenium test case, like this,

 WebDriver driver = new FirefoxDriver();
        FluentWebDriver fwd = new FluentWebDriver(driver);

        driver.manage().timeouts().implicitlyWait(5L, TimeUnit.SECONDS);
        driver.get("http://www.justdial.com/Bangalore/Tape-Dealers-%3Cnear%3E-Bangalore-City-Railway-Station/ct-12976/page-5");

       String res = driver.getPageSource();

it opens up the web browser and starts downloading all the images that are there in the page and caues a delay for the source code to be downloaded from my java program. how can i avoid opening up my browser in this scenario?? i just want the page source and NO graphical content. and hence avoid the delay too... please help!! thanks in advance!!

Upvotes: 2

Views: 1608

Answers (1)

djonsson
djonsson

Reputation: 623

I haven´t used FluentWebDriver but I guess you could try replacing the FirefoxDriver with the HtmlUnitDriver:

Replace:

WebDriver driver = new FirefoxDriver();

With:

HtmlUnitDriver driver = new HtmlUnitDriver();

Upvotes: 1

Related Questions