I want to set some proxy setting in internet explorer with the help of webdriver.
Currently I am using this code :
System.setProperty("webdriver.ie.driver", "Path to IEDriverServer.exe");
Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("proxyhost:port");
DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());
capability.setCapability(CapabilityType.PROXY, proxy);
driver=new InternetExplorerDriver(capability);
But it does nothing except giving this message on console :
org.openqa.selenium.browserlaunchers.WindowsProxyManager backupRegistrySettings
INFO: Backing up registry settings...
I have done the settings related to zone and all which are necessary for using IEDriver.
I am able to use Internet explorer through webdriver without using Proxy configuration.
I am using IE9 on Windows 7 with IEDriver.exe version 2.28.0.
Can somebody suggest me some work around for this.Any help is much appreciated.
Possible workaround : Set the PAC file manually in IE. Simply launch the IEdriver. The bad part is is you would keep switching it if u use IE for surfing..
Related
Very new to Selenium testing and after reading the doc I tried to setup my own Selenium Grid Hub but I'm failing to use it for my local testing.
I setup the Selenium Grid Hub on a kubernetes cluster (following https://github.com/kubernetes/examples/tree/master/staging/selenium) and I manage to reach my nodes.
I've built a simple java application to test this is working as expected and I manage to reach web based url like http://www.google.com but I would like to be able to test my local app by using my RemoteWebDriver.
Here is what is actually working:
log.info("test selenium");
ChromeOptions chromeOptions = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL("http://my-k8-node.com:32223/wd/hub"), chromeOptions);
driver.get("http://www.google.com");
String pageSource = driver.getPageSource();
log.info(pageSource);
driver.quit();
But I get a This site can't be reached - localhost refused to connect. with
driver.get("http://localhost:8080/health/check");
The same with
driver.get("http://host.docker.internal:8080/health/check");
Or with
driver.get("http://127.0.0.1:8080/health/check");
I didn't find any documentation on how to achieve this kind of setup but any hint is welcome.
I would like to further integrate the selenium testing to my Gitlab CI/CD so I should be able to run the test from a "local" point of view.
Thanks for reading.
Please refer to the attached screenshot, I need to save data from 'Save all as HAR' option automatically.
I doubt that selenium provides a way to interact with the inspector. You might have to do something like inject Javascript into the page that re-submits the request and then saves the response/request data on the page in a hidden element. You could then simply get the text from that hidden element via selenium.
Hope that helps
No, Selenium is not the tool you want to use to do this. JMeter may be useful, or this site suggests using a proxy server to do this for you.
Selenium does not give you the ability to track network traffic. It does however allow you to configure a proxy that the browser will use when it is started up.
S to get around your problem you will need to use something like the BrowserMobProxy:
BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
browserMobProxy.start();
Proxy proxy = ClientUtil.createSeleniumProxy(browserMobProxy, InetAddress.getLoopbackAddress());
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(capabilities);
You can then perform some actions with Selenium and when you want to collect a Har file perform:
browserMobProxy.getHar();
For more information about the BrowserMobProxy have a look at the BrowserMobProxy Homepage
I am using Selenium webdriver with firefox. I am wondering if there is a setting i can change such that it to only requesting resources from certain domains. (Specifically i want it only to request content which is on the same domain as the webpage itself).
My current set up, written in Python, is:
from selenium import webdriver
firefox_profile = webdriver.FirefoxProfile()
## Here, I change various default setting in Firefox, and install a couple of monitoring extensions
driver = webdriver.Firefox(firefox_profile)
driver.get(web_address)
What i want to do, is if i specify the web address wwww.domain.com, then to only load content served by domain.com, and not e.g. all the tracking content hosted by other domains that would typically be requested. Hoping could be achieved by a change to the profile settings in firefox, or via an extension.
Note - there is a similar question (without an answer) - Restricting Selenium/Webdriver/HtmlUnit to a certain domain - but it is four years old, and i think Selenium has evolved a lot since then.
With thanks to Vicky, (who's approach of using Proxy settings i followed - although directly from Selenium), the code below will change the proxy settings in firefox such that it will not connect to a domain except that on the white-list.
I suspect several setting changes are unnecessary and can be omitted for most purposes. Code in Python.
from selenium import webdriver
firefox_profile = webdriver.FirefoxProfile()
## replace desired_domain.com below with whitelisted domain. Separate domains by comma.
firefox_profile.set_preference("network.proxy.no_proxies_on","localhost,127.0.0.1,desired_domain.com")
firefox_profile.set_preference("network.proxy.backup.ftp","0.0.0.0")
firefox_profile.set_preference("network.proxy.backup.ftp_port",1)
firefox_profile.set_preference("network.proxy.backup.socks","0.0.0.0")
firefox_profile.set_preference("network.proxy.backup.socks_port",1)
firefox_profile.set_preference("network.proxy.backup.ssl","0.0.0.0")
firefox_profile.set_preference("network.proxy.backup.ssl_port",1)
firefox_profile.set_preference("network.proxy.ftp","0.0.0.0")
firefox_profile.set_preference("network.proxy.ftp_port",1)
firefox_profile.set_preference("network.proxy.http","0.0.0.0")
firefox_profile.set_preference("network.proxy.http_port",1)
firefox_profile.set_preference("network.proxy.socks","0.0.0.0")
firefox_profile.set_preference("network.proxy.socks_port",1)
firefox_profile.set_preference("network.proxy.ssl","0.0.0.0")
firefox_profile.set_preference("network.proxy.ssl_port",1)
firefox_profile.set_preference("network.proxy.type",1)
firefox_profile.set_preference("network.proxy.share_proxy_settings",True)
driver = webdriver.Firefox(firefox_profile)
driver.get(web_address_desired)
I think it is still impossible in selenium.But you can still achieve this by using proxies like browsermob. Webdriver integrates well with browsermob proxy.
Sample pseudeocode in java
//LittleProxy-powered 2.1.0 release
LegacyProxyServer server = new BrowserMobProxyServer();
server.start(0);
// Blacklist websites
server.blacklistRequests("https?://.*\\.blocksite\\.com/.*", 410);//these sites will be blocked
/// get the Selenium proxy object
Proxy proxy = ClientUtil.createSeleniumProxy(server);
// configure it as a desired capability
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, proxy);
// initialize the driver with the capabilities ;
Webdriver driver = new FirefoxDriver(capabilities);
Hope this helps you.Kindly get back if you need any further help
The application I'm testing requires a login with the user's Google account. Every time I log in, it displays/requires that I select the 'Allow Access' button as if it doesn't remember that I have already added it to my list of Authorized Access for my Google account. This doesn't happen when I test manually, only when I'm running Selenium. Has anyone come across an issue like this or know of a solution? Thanks in advance.
WebDriver driver = selenium_driver.get(); // using chrome driver
baseUrl = defaults.getProperty("base_url"); // this is set to my localhost
helper.ConnectToURL(baseUrl);
When this started happening, I had been using Selenium 2.28.0--since then, I've updated to 2.31.0 but it's exhibiting the same behavior.
Disclaimer: This is currently not possible according to the ChromeDriver wiki. It states in the "Known Issues" section "Cannot specify a custom profile". (https://code.google.com/p/selenium/wiki/ChromeDriver)
At some point when it is fixed, I would suggest creating or using the default chrome profile that has your authorized access set that your test uses whenever it starts up.
According to the ChromeDriver wiki: "By default, ChromeDriver will create a new temporary profile for each session".
Checkout this post for more in depth information regarding capabilities: http://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches
I do my work in .NET and Windows; my set up would look something like this:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("start-maximized");
chromeOptions.AddArgument("user-data-dir=C:\\Users\\username\\AppData\\Local\\Google\\Chrome\\User Data\\Default");
capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(ChromeOptions.Capability, chromeOptions);
ChromeDriver chromeDriver= new ChromeDriver(this.Environment.ChromeDriverLocation, chromeOptions);
If you are not limited to using Chrome for your tests you are able to create and use custom profiles using Firefox.
I am setting up the Virtual Environment for my grid-based Webdriver tests. And sure enough, there are problems with IE driver.
First of all, Internet Options → Security should have the same Protected Mode setting. It's an easy fix if you have an access to the browser, but in my case, I won't have physical access to the browser.
In Webdriver's FAQ it says you can do the following:
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.set(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(capabilities);
Ruby bindings have no reference to setting up this capability in IE. It there a way to code it out in Ruby?
The other thing is what can be done against "unsecure connection" pop-ups? Again, they are easy to deal with manually after the first run, but what about running "clean" IE instance each time?
There are probably more concerns,
I'd like to hear your opinion.
Thank you!