Selenium WebDriver_ Access page without opening browser

Asked

Viewed 3,815 times

4

Can anyone tell me if it is possible to access the page without opening a browser? That is, do the tests without opening the browser.

Is there any way? If there’s a light.

I’m using the Firefox browser

2 answers

3

Yes. Enough install Phantomjs.

Then you change the webdrive from:

driver = webdriver.Firefox()

for:

driver = webdriver.PhantomJS()

The rest of the code I believe you will not need to change.

  • Perfect, but it works in JAVA right? and I’ll have to use another browser?

  • @Thiagocosta he is another browser, only without interface... does everything in background.

  • To complement: depending on the complexity of the test, some care should be taken with phantonjs, it does not accept downloading files like any other common browser and neither runs nor even recognizes the flash. Yes, they are stupid limitations, but to test the availability of a link download or check if such a frame containing a flash element loaded without errors, phantonjs can not do this job.

  • @Thiagocosta works in Java yes.

1

There’s a simple way to solve this problem... Just replace the default Webdriver creation

Of:

WebDriver driver = new ChromeDriver();

To:

ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
WebDriver driver = new ChromeDriver(options);

Simple like this, I hope I helped! See you later!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.