Selenium not go to url when open profile firefox [duplicate] - selenium

As the documentation states, you can call webdriver.FirefoxProfile() with the optional argument of profile_directory to point to the directory of a specific profile you want the browser to use. I noticed it was taking a long time to run this command, so when I looked into the code, it looked like it was copying the specified profile Problem is, it takes an extremely long time for the profile to copy (something like >30 minutes, didn't have the patience to wait for it to finish.)
I'm using a hybrid of userscripts and selenium to do some automation for me, so to setup a new profile every single time I want to test out my code would be burdensome.
Is the only way to change this behaviour to edit the firefox_profile.py itself (if so, what would be the best way to go about it?)?

As per the current implementation of GeckoDriver with Firefox using the FirefoxProfile() works as follows :
If case of initiating a Browsing Session through a new Firefox Profile as follows :
from selenium import webdriver
myprofile = webdriver.FirefoxProfile()
driver = webdriver.Firefox(firefox_profile=myprofile, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
A new rust_mozprofile gets created on the run as follows :
1521446301607 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\ATECHM~1\\AppData\\Local\\Temp\\rust_mozprofile.xFayqKkZrOB8"
Of-coarse on a successful closure (i.e. successful invocation of driver.quit()) the temporary rust_mozprofile.xFayqKkZrOB8 gets deleted/destroyed completely.
Again in case of initiating a Browsing Session through an existing Firefox Profile() as follows :
from selenium import webdriver
myprofile = webdriver.FirefoxProfile(r'C:\Users\AtechM_03\AppData\Roaming\Mozilla\Firefox\Profiles\moskcpdq.SeleniumTest')
driver = webdriver.Firefox(firefox_profile=myprofile, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
Similarly a new rust_mozprofile gets created on the run as follows :
1521447102321 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\ATECHM~1\\AppData\\Local\\Temp\\rust_mozprofile.2oSwrQwQoby9"
Similarly in this case as well on a successful closure (i.e. successful invocation of driver.quit()) the temporary rust_mozprofile.2oSwrQwQoby9 gets deleted/destroyed completely.
So the timespan you are observing is the time needed for a FirefoxProfile() to scoop out a new rust_mozprofile.
Perhaps as per your question timespan for profile to copy (something like >30 minutes) is a pure overhead. So it won't be possible to use a Firefox Profile without making a copy of rust_mozprofile.
Solution
Upgrade Selenium Client to current levels Version 3.11.0.
Upgrade GeckoDriver to current GeckoDriver v0.20.0 level.
Upgrade Firefox version to Firefox Quantum v59.0.1 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Firefox base version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Firefox Quantum.
Execute your #Test.

Related

Python Selenium Remote Webdriver(Chrome Webdriver via Selenium Grid), created but does not open browser

I have the following setup:
A Selenium server hub running at "http://localhost:hubPortNum" (a service with the Jar file selenium-server-standalone-3.141.5.jar with parameter -role hub).
A Selenium Node at running "http://localhost:nodePortNum' (the service with Jar file with parameters: -Dwebdriver.chrome.driver=ChromeWebdriverPath -role node -port :nodePortNum).
I checked the URL for the hub and node instances to be sure they are working.
Whenever I try to create Remote Webdriver via Python script:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desiredCapabilities = DesiredCapabilities.CHROME.copy()
chromeOptionsRemote = webdriver.ChromeOptions()
chromeOptionsRemote.add_argument("--start-maximized")
chromeOptionsRemote.add_argument("--disable-session-crashed-bubble")
initRemoteDriver = webdriver.Remote(options=chromeOptionsRemote, command_executor='http://127.0.0.1:<nodePortNum>/wd/hub', desired_capabilities=desiredCapabilities)
print(initRemoteDriver.current_url)
The last line does print the current URL(which is "data:,"), that means Webdriver is created.
But the browser does not open on my local machine, that is it is running in the background and I don't know how to make it visible although it has worked in the past.
The troubleshooting steps I have made:
Reinstall latest selenium python package.
Re-Download latest Selenium server jar file.
Updating chrome.
adding chromeOptionsRemote.add_argument("--no-sandbox")
Making sure local Webdriver does open:
That is the line:
self.localDriver = webdriver.Chrome(options=chromeOptionsLocal,
desired_capabilities=desiredCapabilities)
does open the browser locally(the Chromedriver is in the path).
After I made these troubleshooting steps, I have tried the same configuration on a remote server and got the same result(browser not visible), so I think this is probably by design.
what configuration should I create for the browser to be visible?
Any help would be appreciated.
I was running the jar file by Always-Up: https://www.coretechnologies.com/products/AlwaysUp/
The problem was related to session 0 isolation: https://stackoverflow.com/a/26752251/2710840
in order to not run the application under session 0, I have enabled the Autologon feature:
defined the user under the application run as my user:
and executed the application from the context menu with the option to: "restart in this session"

JMeter with Webdriver Sampler - Browser window not opening

I am running Jmeter with the Webdriver plugin installed on Windows 7. My current test plan contains the Webdriver sampler and Firefox driver config. When I try to run the test plan, nothing happens. There is nothing recorded in the View Results Tree window, and the remaining test indicator in the top right hand corner counts down to 0 without anything happening.
When I deactivate the Webdriver Sampler and Firefox driver config elements, the remaining tests run without a problem.
Is there a bug with this software, or am I missing something? My code is below, if that helps.
var pkg = JavaImporter(org.openqa.selenium)
WDS.sampleResult.sampleStart()
WDS.browser.get('https://test.test.test.test') var username =
WDS.browser.findElement(pkg.By.id('USERNAME')).sendKeys([WDS.args[0]])
var password =
WDS.browser.findElement(pkg.By.id('PASSWORD')).sendKeys([WDS.args[1])
WDS.sampleResult.sampleEnd()
I have installed firefox 26, as this is the recommended supported browser, so it's not that there's no compatible browser.
My main question is this - Why doesn't the browser window open? Why do the other tests in the test plan fail to run when the config elements are active?
In 99% of cases the answer should be in jmeter.log file. In the meantime a couple of recommendations:
add the following line to system.properties file (lives in the /bin folder of your JMeter installation)
webdriver.firefox.bin=/path/to/your/firefox.exe
See https://code.google.com/p/selenium/wiki/FirefoxDriver page for other Firefox-related properties
locate all duplicate http* libraries like httpcore*.jar httpmime.jar etc. and remove the ones with lesser version
restart JMeter to pick the property and the changes up
Check out The WebDriver Sampler: Your Top 10 Questions Answered guide for other tips and tricks
You need to make sure you provided the full path of the Firefox driver in the jp#gc config element.

Where do I see what firefoxdriver selenium starts while testing?

I have installed firebug for FF. But when i start firefox it always starts some default ff version, i dont' know where selenium finds it.
I already googled alot, tried to use different firefoxbinary:
System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
final File firefoxPath = new File(System.getProperty("webdriver.firefox.bin")) ;
FirefoxBinary firefoxBinary= new FirefoxBinary(firefoxPath);
firefox = new FirefoxDriver(firefoxBinary,null);
I tried to use different ff profile:
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.9.1");
Alas, it does not work!
1. I don't know where to change/find webdriver.firefox.bin
2. I have tried changing path as environment variable,still no progress
maybe I m doing something wrong?
By default, Selenium will open a "vanilla" Firefox profile. If you want to have it launch with your profile, you can do that, but you have to select which profile you want to use. I will warn you that you often don't want to have your regular profile used because you'd like a clean, consistent working environment.
But you could certainly:
set up a profile (call it, for instance, selenium-profile using
Firefox's profile manager
run Firefox choosing that profile--from
Windows's Run dialog run "c:\Program Files(x86)\Mozilla
Firefox\firefox.exe" - P" or the equivalent path to FF if you are
32-but.
install Firebug using that profile.
then choose that profile when you launch your tests.
For information about how to do all this, look at this article.
Then, in your code, you can just call that profile. Step 3 in the article linked above shows how to do this.
Firefoxdriver starts a new default profile on each instance and this profile will be created in your temp folder and will be deleted after you quit the driver. There might be some old instances of ff profile which contains older version of firebug in your temp folder which might be not be deleted as webdriver quited unexpectedly.Try clearing your temp. It might help you as it did for me.

Chrome Driver Error using Selenium: Unable to Discover Open Pages

I'm getting a Chrome Driver related error when running my Selenium tests. The error message is "Unable to Discover Open Pages." The Selenium tests were all running fine until last evening. The problem seemed to begin after a reboot of the server the day before. I cannot reproduce this error on my local box. Running the Selenium tests from the command line on the server does open the Chrome Browser but results in the same error. Any ideas?
Line that is failing:
chromeDriver = new OpenQA.Selenium.Chrome.ChromeDriver(externalDriverPath);
Error message and stacktrace:
unable to discover open pages (Driver info:
chromedriver=2.1,platform=Windows NT 6.1 SP1 x86_64) at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse) at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters) at
OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities
desiredCapabilities) at
OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor
commandExecutor, ICapabilities desiredCapabilities) at
OpenQA.Selenium.Chrome.ChromeDriver..ctor(String
chromeDriverDirectory, ChromeOptions options) at
OpenQA.Selenium.Chrome.ChromeDriver..ctor(String
chromeDriverDirectory) at SeleniumTests.BaseTest.SetupBrowsers()
When creating an instance of the ChromeDriver, a console window appears. The server with the error seems to refer to things NOT IMPLEMENTED.
ChomeDriver Output From the Server with the Error:
Started ChromeDriver (v2.1) on port 2984
[4700:4292:0108/111503:ERROR:gpu_info_collector_win.cc(102)] Can't
retrieve a va lid WinSAT assessment.
[4700:4292:0108/111503:ERROR:chrome_views_delegate.cc(176)] NOT
IMPLEMENTED
[4700:4292:0108/111503:ERROR:desktop_root_window_host_win.cc(746)] NOT
IMPLEMENT ED [0108/111504:ERROR:gl_surface_egl.cc(132)] eglInitialize
failed with error UNKNO WN [0108/111504:ERROR:gl_surface_win.cc(97)]
GLSurfaceEGL::InitializeOneOff failed.
ChomeDriver Output From My PC which works fine:
Started ChromeDriver (v2.1) on port 18786
[884540:883760:0108/114010:ERROR:gpu_info_collector_win.cc(102)] Can't
retrieve a valid WinSAT assessment.
[884992:884996:0108/114010:ERROR:base_feature_provider.cc(122)]
manifestTypes: A llowing web_page contexts requires supplying a value
for matches.
[885232:885236:0108/114011:ERROR:base_feature_provider.cc(122)]
manifestTypes: A llowing web_page contexts requires supplying a value
for matches.
[884540:883760:0108/114011:ERROR:base_feature_provider.cc(122)]
manifestTypes: A llowing web_page contexts requires supplying a value
for matches. [0108/114011:ERROR:gl_surface_egl.cc(131)] eglInitialize
failed with error UNKNO WN [0108/114011:ERROR:gl_surface_win.cc(54)]
GLSurfaceEGL::InitializeOneOff failed.
You are using a highly outdated version of the ChromeDriver. Your first port of call should be to update it here.
I would highly suspect the problem is your Chrome on your server has updated, and ChromeDriver v2.1 doesn't support any recent versions of Chrome.
Look here for other possible solutions: https://groups.google.com/forum/?hl=en#!topic/selenium-users/gfvfH-YEC48
In my case, adding the --no-sandbox argument to ChromeOptions solved the problem.
Here's a quick workaround I found while digging around to get rid of that error: unknown error: unable to discover open pages
In your protractor config file, add the following:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox']
}
},
The most important line there is the --no-sandbox; adding that line somehow gets rid of that error.
I am not exactly sure why it works but it's a workaround I found while digging around online.
***********************************UPDATES as of 10/04/2016***********************************
Please ignore this part right above as that workaround is NOT a proper fix; below I show you the actual fix to your problem; you just have an outdated chrome driver and running "webdriver-manager update" will only update up to v2.22 so I'll show you how to grab v2.24 right below.
Read on if your webdriver-manager update doesn't update chromedriver
to the latest i.e past v2.22 OR to v2.24 as of 10/04/2016.
I lost a few weeks pulling my hair around an issue I had with "Unable to discover open pages" and every time I would update the chromedriver, it would update to version 2.22 for chromedriver and I believe the selenium server to v2.53.
My problem wasn't really with the selenium server so v2.53 was fine.
Issue was with chromedriver v2.22.
Eventhough this chromdriver link showed that there was a latest version of 2.24, 'webdriver-manager update' would NOT pick up that latest version, it would only grab version 2.22 of the chrome driver.
How did I go around this?
Simply run the command below after you check this link for which version of chromedriver you want to update to; for instance, I wanted v2.24 so I ran the command below:
webdriver-manager update --versions.chrome 2.24
If you check your location: C:\Users\<USER>\AppData\Roaming\npm\node_modules\webdriver-manager\selenium\
You should see that the desired chromedriver was downloaded there; if it's not there, read the command prompt logs and it'll tell you where it downloaded your chromdriver files.
Hope that helps someone!
I had the same problem, but updating to the latest ChromeDriver (v2.8) did not solve it for me. I was running Selenium on a CI server (A Dell machine running 64 bit Win 7). I got the exception every time when the server had been 'idle' for a while.
What fixed the problem for me was to set 'Turn off display after' in Windows' Power Options to 'Never'.
I am running selenium with python in Docker on a Google compute instance. For me, the issue was that my instance didn't have enough memory, and my scrape job would fail with this error. Upgrading it to g1-small resolved the issue for me.
In my case the problem was due to one of my colleagues, who started his tests at the same time on the same server, so that my web driver could not access the Chrome executable. It also happens if someone didn't finish his web driver process properly, in this case you have to kill it manually.
First make sure you have updated you chrome browser, through the Menu UI.
Then update ChromeDriver, here.
For some reason the Chrome driver cannot interpret https traffic. If you change your link to http it will work nicely.

Selenium RC: "waiting for window 'null' local frame 'null'"

I am totally at a loss here, trying to run a minimal Selenium RC style test. The issue I'm experiencing has been described by a lot of users on the web but none of the widely varying solutions solved the problem in my case. What happens is that Firefox will open, but with what looks like an empty profile to me, because it opens the "Welcome to Firefox!" page. Apart from that, nothing happens in the browser and in the Selenium server log I find this:
DEBUG [12] org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory - Requested browser string '*firefox c:\progra~2\mozill~1\firefox.exe' matches *firefox
DEBUG [12] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Firefox 3 launcher at :'c:\progra~2\mozill~1\firefox.exe' is valid...
DEBUG [12] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Discovered valid Firefox 3 launcher : 'c:\progra~2\mozill~1\firefox.exe'
INFO [12] org.openqa.selenium.server.BrowserSessionFactory - Allocated session 962d2221ccb4459b9adbad1b8734850c for http://www.google.com, launching...
DEBUG [12] org.openqa.selenium.server.browserlaunchers.ResourceExtractor - Extracting /customProfileDirCUSTFFCHROME to C:\Users\zb\AppData\Local\Temp\customProfileDir962d2221ccb4459b9adbad1b8734850c
INFO [12] org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher - Preparing Firefox profile...
INFO [12] org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher - Launching Firefox...
DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1800 more secs
DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - got condition? : false
The last three lines are then repeated every second until I stop the Selenium server again.
This is my test code:
import com.thoughtworks.selenium.DefaultSelenium;
public class Runner {
public static void main(String[] args) {
DefaultSelenium selenium = new DefaultSelenium("localhost", 4444,
"*firefox c:\\progra~2\\mozill~1\\firefox.exe",
"http://www.google.com");
selenium.start();
selenium.open("/");
selenium.type("q", "test");
selenium.click("btnK");
selenium.stop();
}
}
I tried:
different versions of Firefox (22, 21, 20)
different versions of Selenium server (2.33.0, 2.25.0, 2.15.0, a CI build)
different versions of the Selenium client driver
different versions of the Oracle JDK (1.6u24, 1.6u45, both 32- and 64-bit versions)
various Firefox browser launchers in the test code
specifying the browser path in the test code or not
running Selenium server as Administrator or not
various Selenium server options (with/out custom profile, multi-window mode, etc.)
different locations for Firefox and the custom profile (i.e. path with/out spaces)
a similiar test like the Java one above, written in Perl
It all doesn't help and ends up like I described above. I'm on a Windows 7 machine (64bit). By the way, a small WebDriver test I tried works as expected.
Edit: Renamed question, because the server doesn't actually "hang", it just doesn't work as expected.
I went back to Firefox 17 ESR (Extended Support Release) and suddenly the tests came back to life (using Selenium server 2.33.0).
This problem seems to be an indicator for version incompatibilites between Selenium server and Firefox. Unfortunately, there's not much, or anything, to be found in the documentation on this matter - but then again, as #Pavel Janicek mentioned, Selenium RC is deprecated. What I've been able to grasp from the CHANGELOG is that Selenium server 2.32.0 explicitly supports Firefox 10 ESR, 17 ESR, 19 and 20. For 2.33.0, no additional browser versions are mentioned, leaving Firefox 21+ officially unsupported, although not everyone agrees.
To wrap it up: If you see this error, the only solution may be to step down the list of supported browsers in the current CHANGELOG until your tests run again.
I hit the same problem, but I could get around it by updating to selenium-server-standalone-2.35.0.jar from https://code.google.com/p/selenium/downloads/list, with Firefox version 24 installed on Ubuntu 12.04 using apt-get (version is 24.0+build1-0ubuntu0.12.04.1).