Providing path to Firefox/Chrome/IE installation in cygwin - selenium

I'm trying to launch Firefox remotely on a windows machine from UNIX box using remotewebdriver.
I've tried by adding Firefox in the PATH as below:
$ echo $PATH
/cygdrive/c/Program Files (x86)/Google/Chrome/Application/:/cygdrive/c/Program Files (x86)/Mozilla Firefox/
But still the browser fails to launch as the geckodriver.exe tries to find Firefox in the windows default path.
Here is the log from selenium hub:
1486475449767 mozprofile::profile INFO Using profile path
C:\cygwin64\tmp\rus
t_mozprofile.Rmyr2i85U1HV
1486475449774 geckodriver::marionette INFO Starting browser
C:\Program Files (x86)\Mozilla Firefox\firefox.exe
I also tried adding below property while launching selenium node:
-Dwebdriver.firefox.bin="/cygdrive/c/Program Files (x86)/Mozilla Firefox/"
However, the exception was thrown:
Caused by: org.openqa.selenium.WebDriverException: 'webdriver.firefox.bin' property set, but unable to locate the requested binary: /cygdrive/c/Program Files (x86)/Mozilla Firefox/.exe
..........
Exception: Could not initialize class org.openqa.selenium.firefox.internal.Executable
Is there a way to provide the path to the firefox installation folder?
EDIT:
After providing parameters:
-Dwebdriver.gecko.driver=geckodriver.exe -Dwebdriver.firefox.bin="firefox/firefox.exe"
The execution gets stuck at:
1486534065121 mozprofile::profile INFO Using profile path C:\cygwin64\tmp\rust_mozprofile.eqdfIaNAGjDu
1486534065135 geckodriver::marionette INFO Starting browser >C:\cygwin64\home\Administrator\firefox\firefox.exe
1486534065198 geckodriver::marionette INFO Connecting to Marionette on localhost:56702
1486534068740 Marionette INFO Listening on port 56702

Try escape characters and specify the .exe file:
-Dwebdriver.firefox.bin="/cygdrive/c/Program Files\ (x86)/Mozilla Firefox/firefox.exe"

Related

Getting error while invoking the chrome browser using selenium

This is the error I am getting while running a selenium program
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from https://chromedriver.storage.googleapis.com/index.html
at org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:280)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:135)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:38)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:231)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:437)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:127)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:46)
at Selintroduction.main(Selintroduction.java:17)

Error: Can't find profile directory. console.warn: SearchSettings: "get: No settings file exists, new profile?" using GeckoDriver Firefox and Selenium

[RemoteTestNG] detected TestNG version 7.3.0
1609754675168 geckodriver INFO Listening on 127.0.0.1:123456
1609754675873 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\username\\AppData\\Local\\Temp\\rust_mozprofileomKd1k"
Can't find symbol 'eglSwapBuffersWithDamageEXT'.
Can't find symbol 'eglSetDamageRegionKHR'.
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))
1609754679973 Marionette INFO Listening on port 53339
1609754680041 Marionette WARN TLS certificate errors will be ignored for this session
Jan 04, 2021 3:34:40 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
FirefoxDriver: firefox on WINDOWS (f53578b1-71b7-46a7-85ef-8bfd18ba1bc2)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/C:/Users/S%20K%M/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar) to field java.io.FilterInputStream.in
WARNING: Please consider reporting this to the maintainers of org.apache.poi.openxml4j.util.ZipSecureFile$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
JavaScript warning: https://resulticks.team/Scripts/Commonfunction.js, line 147: unreachable code after return statement
JavaScript warning: https://resulticks.team/Scripts/Commonfunction.js, line 147: unreachable code after return statement
1609754783815 Marionette INFO Stopped listening on port 53339
###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
Given implicit wait time
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Same code working in chrome..
For firefox below code used for launch:
private synchronized ThreadLocal createFirefoxDriver()
{ // FF Profile
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "/driver/geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile testprofile = profile.getProfile("Selenium");
FirefoxOptions foptions = new FirefoxOptions();
foptions.setProfile(testprofile);
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("marionatte", false);
foptions.merge(dc);
driver.set(new FirefoxDriver(foptions));
return driver;
}
Thanks #DebanjanB..Still my issue not resolved.. After running script by using profile
[RemoteTestNG] detected TestNG version 7.3.0
1609825445685 geckodriver INFO Listening on 127.0.0.1:2634
1609825469323 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\SKMAST~1\\AppData\\Local\\Temp\\rust_mozprofileVF0L8V"
Can't find symbol 'eglSwapBuffersWithDamageEXT'.
Can't find symbol 'eglSetDamageRegionKHR'.
1609825472726 Marionette INFO Listening on port 64263
1609825473031 Marionette WARN TLS certificate errors will be ignored for this session
Jan 05, 2021 11:14:33 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
JavaScript warning: https://weburl/Scripts/Commonfunction.js, line 147: unreachable code after return statement
1609825500246 Marionette INFO Stopped listening on port 64263
JavaScript error: https://weburl/DashBoard/Index, line 2521: ReferenceError: LoadingPanelDisplay is not defined
###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
My Issue is
In my application after login, trying to find element without loading page element found message and capturing screenshot. in another case after login, I have to click element without loading page element clicked message showing after few seconds page loaded. but same code working in chrome.
This error message...
Can't find symbol 'eglSwapBuffersWithDamageEXT'.
Can't find symbol 'eglSetDamageRegionKHR'.
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))
...implies that the firefox-profile by the name Selenium doesn't exist.
Solution
Before you try to access the firefox-profile by the name Selenium you have to create it first following the steps mentioned in Creating a new Firefox profile on Windows
References
You can find a couple of relevant detailed discussions in:
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)")) using Selenium and Java
Cannot resolve constructor FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)
How to use both the Firefox Profile and Firefox options with Selenium in Java
Selenium Tests take several minutes to start when loading a profile

Jenkins starts chromedriver in background mode (like headless mode)

I've setup Jenkins server on windows 10 machine. When running the job(simply mvn test -DsuiteXmlFile=%TestSuite%) the job successfully compiles and starts tests. I can see first being skipped, second failed and then it starts passing one after one. No Chrome window is opened, but when I check in task manager I can see it opens several Chrome processes in background. When calling mvn test -DsuiteXmlFile=TestSuite in CMD(also in power shell) it opens Chrome in front.
Looking at Jenkins logs I see that it creates a .bat file in c:/System/TEMP/ directory and executes that batch file. I've even tried to copy the file, put in my project's root and call it via CMD, the same .bat file works as expected. Still jenkins opens Chrome in background. Any idea what causes this and how can I force Jenkins to run tests in Foreground?
My chromedriver vesion is 78.0.3904.70(if needed).
Logs are identical for both cases:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
18.11.2019 03:50:38.019 INFO - [AutomationListener]:Staring to run test suite with 11 tests
Nov 18, 2019 3:50:38 AM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904#{#800}) on port 39924
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1574077841.726][WARNING]: Timed out connecting to Chrome, retrying...
Nov 18, 2019 3:50:43 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1574077845.835][WARNING]: Timed out connecting to Chrome, retrying...
18.11.2019 03:50:55.489 INFO - [BasePage]:The element: By.cssSelector: polygon is clicked
18.11.2019 03:50:55.494 INFO - [AutomationListener]:----------------------------------------------------------------------
18.11.2019 03:50:55.495 INFO - [AutomationListener]:Starting to run TestMethod test method
18.11.2019 03:50:55.495 INFO - [AutomationListener]:----------------------------------------------------------------------
When the Jenkins slave run as service in the background every program it initiate, like running the batch file, will also be in the background. The solution is to run the Jenkins slave as a regular program in the foreground.
Yes, the slave solution is working in my case.
I have also a window machine, I have configured the Jenkins and also configured the slave within the machine and now it every time opens the browser in the foreground.
I know it's not the genuine solution but it works perfectly

Jenkins and Seleniumhq configuration

I'm trying to set up a simple Selenium test in Jenkins. My OS is Debian GNU/Linux 6.0.7 (squeeze), desktop version (64-bit). I uninstalled the supplied browser iceweasel and intalled Firefox with aptitude. The firefox version is "20.0". I also have Google Chrome installed. I can run Firefox by writing "firefox" in a terminal window.
Jenkins is installed with aptitude.
So, I have installed a plugin in Jenkins called Seleniumhq. These are my settings:
I then receive an error in the Jenkins console when I try to build:
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/selenium2
java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar -trustAllSSLCertificates -htmlSuite *firefox http://site.com /var/lib/jenkins/jobs/Selenium1/suites/suite1.html /var/lib/jenkins/jobs/Selenium1/logs/selenium.html
[selenium2] $ java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar - trustAllSSLCertificates -htmlSuite *firefox http://site.com /var/lib/jenkins/jobs/Selenium1/suites/suite1.html /var/lib/jenkins/jobs/Selenium1/logs/selenium.html
13:32:18.507 INFO - Java: Sun Microsystems Inc. 14.0-b16
13:32:18.508 INFO - OS: Linux 2.6.32-5-amd64 amd64
13:32:18.512 INFO - v2.0 [b2], with Core v2.0 [b2]
13:32:18.604 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
13:32:18.605 INFO - Version Jetty/5.1.x
13:32:18.606 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
13:32:18.606 INFO - Started HttpContext[/selenium-server,/selenium-server]
13:32:18.607 INFO - Started HttpContext[/,/]
13:32:18.616 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#488e32e7
13:32:18.616 INFO - Started HttpContext[/wd,/wd]
13:32:18.621 INFO - Started SocketListener on 0.0.0.0:4444
13:32:18.621 INFO - Started org.openqa.jetty.jetty.Server#5a5e5a50
HTML suite exception seen:
java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(Bro wserLauncherFactory.java:160)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(Browse rLauncherFactory.java:99)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.getBrowserLauncher(HTMLLauncher.java:58)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:114)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:166)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:557)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:250)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:210)
Caused by: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin
at org.openqa.selenium.browserlaunchers.locators.Firefox2or3Locator.findBrowserLocationOrFail(Firefox2or3Locator.java:26)
at org.openqa.selenium.server.browserlaunchers.BrowserInstallationCache.locateBrowserInstallation(BrowserInstallationCache.java:27)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.<init>(FirefoxLauncher.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(BrowserLauncherFactory.java:153)
... 7 more
Finished: SUCCESS
I also tried to put this in the browser field:
*firefox/usr/bin/firefox
I think firefox is installed there (i ran "locate firefox").
That config renders another error msg:
...
HTML suite exception seen:
java.lang.RuntimeException: Browser not supported: *firefox/usr/bin/firefox
Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
....
Does anybody have ideas about how to fix this?
Thanks!
Edit
I changed the browser settings to this:
*firefox /opt/firefox/firefox (with a space between)
Now it seems FIrefox can be found, but I receive another error:
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/selenium2
java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar -trustAllSSLCertificates -htmlSuite *firefox /opt/firefox/firefox http://site.com /var/lib/jenkins/jobs/selenium2/suites/suite1.html /var/lib/jenkins/jobs/selenium2/logs/selenium.html
[selenium2] $ java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar - trustAllSSLCertificates -htmlSuite "*firefox /opt/firefox/firefox" http://site.com /var/lib/jenkins/jobs/selenium2/suites/suite1.html /var/lib/jenkins/jobs/selenium2/logs/selenium.html
10:51:15.567 INFO - Java: Sun Microsystems Inc. 14.0-b16
10:51:15.569 INFO - OS: Linux 2.6.32-5-amd64 amd64
10:51:15.572 INFO - v2.0 [b2], with Core v2.0 [b2]
10:51:15.668 INFO - RemoteWebDriver instances should connect to: http: //127.0.0.1:4444/wd/hub
10:51:15.669 INFO - Version Jetty/5.1.x
10:51:15.669 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
10:51:15.670 INFO - Started HttpContext[/selenium-server,/selenium-server]
10:51:15.670 INFO - Started HttpContext[/,/]
10:51:15.680 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#3da99561
10:51:15.680 INFO - Started HttpContext[/wd,/wd]
10:51:15.685 INFO - Started SocketListener on 0.0.0.0:4444
10:51:15.685 INFO - Started org.openqa.jetty.jetty.Server#182d9c06
10:51:15.743 INFO - Preparing Firefox profile...
HTML suite exception seen:
java.lang.NullPointerException
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:259)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirec tory(FirefoxChromeLauncher.java:117)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:84)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchHTMLSuite(FirefoxChromeLauncher.java:406)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchHTMLSuite(FirefoxLauncher.java:106)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:121)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:166)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:557)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:250)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:210)
10:51:35.789 INFO - Shutting down...
Finished: SUCCESS
Well, I found a good tutorial that turned out to be useful. One important thing is to start a virtual X window on a server where Selenium can start the browser in to run your tests (Xvfb). And in Jenkins the server should be entered just like "*firefox".
http://alex.nederlof.com/blog/2012/11/19/installing-selenium-with-jenkins-on-ubuntu/
You should try to run the commandline from a shell and see what happen. It's certainly a problem linked to the default profile used by the firefox instanciated by selenium.
In my case the problem was that firefox was starting by displaying the tabs that could be restored.
You can also try to create a specific profile :
firefox -p
or
firefox -ProfileManager
then use this dedicated profile using command line parameter :
-firefoxProfileTemplate /home/userXXX/.mozilla/firefox/ljhyckqd.Selenium
java.lang.RuntimeException: Browser not supported: *firefox/usr/bin/firefox
Wrong syntax. try *firefox or *firefox [insert directory]

Selenium suites is not running on Chrome and running on FF?

Case 1:
When using:
C:\Program Files (x86)\Java\jdk1.7.0\bin>java -jar C:\selenium\selenium-2.25.0\selenium-server-standalone-2.25.0.jar -htmlSuite "*googlechrome" https://accounts.google.com/ "C:\selenium\Ide\test_suite.htm" "C:\selenium\Ide\results.htm"
Getting Exception:
HTML suite exception seen: java.lang.RuntimeException:
java.lang.RuntimeException: Google Chrome could not be found in the
path! Please add the directory containing ''chrome.exe' or
'google-chrome' or 'Google Chrome'' to your PATH environment
avariable, or explicitly specify a path to Google Chrome like this:
*googlechrome c:\blah\chrome.exe
Case 2
So Changed
C:\Program Files (x86)\Java\jdk1.7.0\bin>java -jar C:\selenium\selenium-2.25.0\selenium-server-standalone-2.25.0.jar -htmlSuite "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://accounts.google.com/ "C:\selenium\Ide\test_suite.htm" "C:\selenium\Ide\results.htm"
Getting:
HTML suite exception seen:
java.lang.RuntimeException: Browser not supported: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
(Did you forget to add a *?)
Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*webdriver
*iehta
*custom
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.browserNotSupported(BrowserLauncherFactory.java:151)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(BrowserLauncherFactory.java:127)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.getBrowserLauncher(HTMLLauncher.java:78)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:138)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:196)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:612)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:286)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:244)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:54)
23:23:19.194 INFO - Shutting down...
Case 3
So Changed again with browser as *chrome
it should run on chrome but it is running on Firefox
use *googlechrome to run on Chrome browser.
And add the directory containing 'chrome.exe' or 'google-chrome' to your PATH environment.
Note - If you just say *chrome it will invoke Firefox Chrome.
It should also work by updating "*googlechrome" argument as -
"*googlechrome C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"