I have Jenkins running headless on a remote machine(centOS). I am trying to run some automated login tests using Selenium Grid (with both hub and a node on same centOS machine) on a development environment whose security certificate is self signed. So, on the home page, when the login link is clicked, it lands up at https error page, while selenium webdriver expects the login page. So all tests are getting failed. I tried to create firefox profile:
nodeUrl = "http://localhost:4444/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.firefox();
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(false);
capability.setCapability(FirefoxDriver.PROFILE, profile);
capability.setBrowserName("firefox");
capability.setPlatform(Platform.ANY);
driver = new RemoteWebDriver(new URL(nodeUrl), capability);
But this does not work out. How can i make sure that when the node invokes firefox, it accept that untrusted certificate?
Related
i've created browser instance using watir like below:
proxies = ['--proxy-server=hostname:portnumber', '--proxy-auth=username:password']
browser = Watir::Browser.new :chrome, :switches => proxiesle
but the problem above the code is cannot authenticate proxy by passing parameters --proxy-auth=username:password, i was wondering how could i automatically set username and proxy in chrome driver? Some solution was written in java like below:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user:password#proxy.com:8080"));
WebDriver driver = new ChromeDriver(capabilities);
how you guys to override proxy authentication inside chrome ?
Chrome has stopped support for URL authentication system for latest Chrome version.
I have a Java code, which will authenticate pop-up:
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword(username, password));
Convert this code in Ruby.
I ran my test in BrowserStack and here is an example outcome
How can I turn off this behaviour of Firefox in a selenium test via DesiredCapabilities?
I want to be able to drive this behaviour with settings instead of adding code for a specific browser.
This prompt is related to firefox health report, you can disable it in as: (in java)
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("datareporting.healthreport.uploadEnabled", false);
profile.setPreference("datareporting.healthreport.service.enabled",
false);
profile.setPreference("datareporting.healthreport.service.firstRun",
false);
WebDriver driver = new FirefoxDriver(profile);
I am already logged in to my googlemail account in Firefox browser with profile named: test_profile.
Using Selenium, I launch Firefox browser with profile test_profile, but I am seeing login page. Meaning, the session/cookies are not being used.
What am I doing wrong? Or what can be done so I can use my session.
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("test_profile");
WebDriver driver = new FirefoxDriver(profile);
driver.get("https://www.googlemail.com");
Thanks.
My issue is caused by incorrect 'proxy' settings in Firefox so I want to disable the proxy in the profile that Selenium uses for my tests.
Currently my profile looks for the local proxy settings file by default:
file:///C:/Users/%username%/AppData/Local/Temp/customProfileDir536e1d9817834e4e838cad55697fc909/proxy.pac
That file contains these 3 lines:
function FindProxyForURL(url, host) {
return 'PROXY localhost:4444; DIRECT';
}
If during the tests I open the settings and set 'no proxy', the app starts working fine. How can I make the tests always launch with the 'no proxy' setting?
I tried to use the -avoidProxy flag when running the Selenium server but that hasn't helped. I also tried using a separate profile for tests but Selenium overrides its settings as well.
Create a new firefox browser profile & set the preferences in it as per your requirement.
Start selenium server with this profile using the switch -firefoxProfileTemplate <path_to_firefox>
I'm trying to start the selenium server by passing custom firefox profile to the DefaultSelenium constructor. It opens the browser with specified URL.
DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*custom \"C:/Program Files/Mozilla Firefox/firefox.exe\"",ReadConFile.readcoFile("serverName"));
selenium.start();
the log is
16:39:19.246 INFO - Allocated session 4eb63d37a4ba4d2fb4e351f8f59e3ea6 for https://<myURL>, launching...
then it stays like that and server doesn't start.
however, this works fine if I don't use custom profile.
DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome",ReadConFile.readcoFile("serverName"));
selenium.start();
I need the launch custom profile as I've saved some site certificates necessary for https. Also, I'm executing this from eclipse.
I think my server isn't configured to launch custom profile. Please help me with this.
The start command is not really starting your selenium server per se, it's connecting your selenium object to an already running server with the browser of your choice.
To actually start the selenium [Jetty Web] server that sends / receives commands to your application under test via your specified browser, use a batch file and the switch rs79 is referring to. The contents of your batch file should include his line:
java -jar selenium-server-standalone-2.0a5.jar -firefoxProfileTemplate C:\custom-firefox-profile
Now you have a true selenium server running on your dev machine (localhost) with the default "4444" port. This will specify that any Firefox browser testing will use this profile.
Now your DefaultSelenium constructor, assignment, and other calls can look like this:
DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*firefox","http://www.server.com");
selenium.start()
selenium.open("myApp/")
Firefox will start using the custom profile specified in the batch file that starts the Selenium server, with your desired base URL, and then navigate into your desired application [URL]. If you are beginning your test from "http://www.server.com/" and not "http://www.server.com/myApp", you can omit the last open line.
When you invoke the Selenium RC server, specify the path using the additional -firefoxProfileTemplate clause.
For example -
java -jar selenium-server-standalone-2.0a5.jar -firefoxProfileTemplate C:\custom-firefox-profile
This will enable you to use all the bindings you have saved within the custom profile.
If you want to have Fifefox profile as default in your test:
a) Download latest selenium-server: http://selenium-release.storage.googleapis.com/index.html
b) Download latest Firefox
c) Create FF profile (best in your custom directory) - in my case named "atf" https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles
Default directory where profiles are saved:
C:\Users\johndoe\AppData\Roaming\Mozilla\Firefox\Profiles
d) In my case I use FF 36 and selenium-server-standalone-2.45.0.jar
Run selenium server:
java -jar C:\driver\selenium-server-standalone-2.45.0.jar -Dwebdriver.firefox.profile=atf
Then refer to it in your code:
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
If you want to refer to particular profile in your code (here I use default generated folder for profile named "myProfile"):
profile_path = C:/Users/johndoe/AppData/Roaming/Mozilla/Firefox/Profiles/2zvl3dxx.myProfile"
fp = webdriver.FirefoxProfile(profile_path)
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX,
browser_profile=myProfile)
You can add certificates to custom profile
a) Run browser with custom profile
b) Add certificate
c) Remember to tick option in Firefox Preferences/Advanced/Certificates
Select one automatically
to avoid asking for accepting certificate every time as you access tested page
d) Restart browser
e) Navigate to page what will be tested and accept User Identification Request
f) Close Firefox and enjoy custom profile with certificates available from selenium server :)
You can also start the Selenium server in java see here.