Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access the application using selenium webdriver that works through VPN?

For example, I have an application "www.test.com", to access this site I have installed browsec VPN in firefox then I can see the application content - accessing the site without vpn I get an error of "Your IP Address has been blocked..bla bla" Now I want to test some UI of that site through Selenium Webdriver, but when I try to access the site via selenium webdriver I get same error of IP blocked since the vpn is already installed on firefox, but webdriver doesn't bother the VPN - that's my question how can I access the such applications through Selenium webdriver?

like image 377
Saba Malik Avatar asked Dec 27 '17 17:12

Saba Malik


People also ask

How do I run Selenium remotely?

Selenium RemoteWebDriver Installation Once the Selenium grid is installed, follow the steps below to configure the Selenium RemoteWebdriver. Open a web browser and navigate to http://localhost:4444/grid/console. The grid console page will be visible. Connect to Selenium Hub to execute test cases.

How do I run a Selenium script in another browser?

Create an XML which will help us in parameterizing the browser name and don't forget to mention parallel="tests" in order to execute in all the browsers simultaneously. Execute the script by performing right-click on the XML file and select 'Run As' >> 'TestNG' Suite as shown below.

Is it possible to run a Selenium test without using a real browser?

We can perform Selenium testing without a browser. This is achieved by triggering the execution in a headless mode. The headless execution can decrease the utilization of key resources and is being adopted widely.


1 Answers

You have to load the extension using firefox profiles in WebDriver. The path to extension file is usually here C:\Users\administrator\AppData\Roaming\Mozilla\Firefox\Profiles\ew0u966b.default-1507268891903\extensions

WebDriver driver = null;

FirefoxProfile firefoxProfile = new FirefoxProfile();
File addonpath = new File("path of addon/extension (.xpi file)");
firefoxProfile.addExtension(addonpath);

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);

driver = new FirefoxDriver(capabilities);

driver.get("http://www.helloselenium.com");

driver.quit();

http://www.helloselenium.com/2014/09/how-to-add-addon-to-firefox-instance-of.html

For chrome see below link

http://www.abodeqa.com/2013/08/24/adding-add-on-in-firefox-and-chrome-using-webdriver/

To start the extension, the following should work.

Every extension will have a unique id which can be used to open the extension in the browser. When you install browsec plugin, you will get a url like this indicating the id. moz-extension://f1b30486-cd88-4319-bbb5-d5e387103414/congratulations.html I am not sure about how to obtain this id in any other way or whether it will be same for different installations. I have asked a question in SO for the same - Get add-on id of extensions in Firefox

Replacing congratulations.html with popup.html should open the extension in the browser. You can then treat this like a normal webpage and automate it using selenium WebDriver. After you start the extension in this way, you can then load the url of the application under test and continue.

enter image description here

like image 63
Sighil Avatar answered Oct 22 '22 19:10

Sighil