Ey guys, im trying to use selenium/Google Chrome to automate some development and testing task. what i want to do is to avoid any X remote session or even VNC to the server, jsut let for example python launch my app that connects to selenium engine under Chrome Browser.
My problem is that of course when im on my ssh session if i try to launch google-chrome or even my selnium plugin i get browser_main_loop.cc(240)] Gtk: cannot open display .
there is anyway that i can send this command to an already opened X session and get the results back?
Thanks!
Related
Problem statement is:
Execute Robothost Testcase -> used Open Connection keyword to connect to machineX. used Open Browser keyword to open Firefox of machineX.
But instead of opening firefox browser of machineX, browser from Robothost is opening from where testcase is getting executed.
But my testcase execution needs to be done on webpage opened in machineX only.
Since used Open Browser after connecting to remote machine, expecting browser of remote machine to be active. verified that connectivity to remote machine is active.
Below is sample code tried to open browser from machineX
*** Testcases ***
LaunchBrowser
Open Connection ${machineX}
Sleep 5s
Open Browser ${base_url}
Sleep 5s
Input Text //input[#id="normal_login_username"] admin
Input Text //input[#id="normal_login_password"] admin
Click Element //button
Sleep 5s
Capture page screenshot filename=output5g.png
Close Browser
Any suggestions to handle this scenario
This is not how the ssh library works, in order to execute something on the machine x you need to use ssh library keywords. The selenium library will be executed on your machine.
You can install robot framework on machine x and execute the test there. Otherwise you cannot use ssh library. You can trigger the test from your machine if you have to do this remotely.
So the concept is like this -
I would like to run the selenium server .jar file on a remote windows machine.
Then connect to it via the default port (:4444), open browser and navigate to a URL of my choosing.
I have everything working except the part of running the selenium server through robot.
This keyword works as far as I can tell (until the open browser keyword) -
Start Selenium Server
&{client} = Return Internal Host
Connect Environment Machine Windows ${client}
start process java -jar ${/}SeleniumServer${/}selenium-server-standalone-3.141.59.jar alias=seleniumserver
process should be running seleniumserver
open browser http://example.com/example.html chrome None http://1.1.1.1:4444/wd/hub
BUT, when I try to connect to the selenium server I get the following error -
"No connection could be made because the target machine actively refused it"
It seems like the process either does not run or runs for a short amount of time then closes.
What am I missing here?
If I manually start the server on the client, everything works. It opens the browser and does whatever I need. (manually running the java -jar selenium*.jar on the cmd)
But when I run this Start process keyword, that should keep the process running in the background, I get connection refused. Any Ideas?
Another piece of information that might be useful - The selenium server should throw an error if trying to run it twice on the same machine (because of the used port bind 4444).
When running the keyword shown above, while there is a selenium server up and running on the target machine, the test still passes for some reason. Not sure if it is even running the process as intended but the "process should be running" keyword seems to pass.
Thanks!
Im running chrome headless through chromedriver and selenium via python.
I've run into the following issue both on Mac and Linux.
Im starting chrome as follows:
if self.headless:
options.headless = True
options.add_argument("--headless")
if self.debug_port:
logging.info(f"Setting up remote debugging on port {self.debug_port}")
options.add_argument(f"--remote-debugging-port={self.debug_port}")
options.add_argument(f"--remote-debugging-address=0.0.0.0")
If I connect to http://localhost:9222 from another headed instance of chrome I can see the list of sessions and connect to it seamlessly. At which point i have a window opened up with a screencast of the remote session and the dev console.
Here's that successful example:
When I connect to http://192.168.1.194:9222 I get the list of sessions just fine and upon selecting one the dev console opens but it doesn't start the websocket connection to ws://192.168.1.194 so the screencast and remote debugging capabilities are not available.
Here's that failed example:
I've captured har files and uploaded them here if you want to take a look
Using the following steps I was able to debug remotely. However the screencast functionality did not work. Ultimately that's what I needed so this is only a 50% solution in my case.
So, as noted above in the comments, what's blocking remote debugging from working is that the chrome debugger links out to https://chrome-devtools-frontend.appspot.com/..... and passes a value of ws://192.168.1.194 for the websocket parameter. Any browser will inherently block this, based on it being mixed content - i.e: https + ws
What's needed here is to run the chrome dev tools frontend on a http server
and direct your chrome instance to that server instead of the appspot instance.
Solution Steps
1 Install depot_tools (pre-requisite for building)
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
2 Checkout the devtools-frontend repo
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#checking-out-source
3 Build chrome devtools frontend
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#build
4 Start the devtools-frontend http server
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#running-in-hosted-mode
5 Run 2 instances of chrome and use one to debug the other
5.1 Start first instance of chrome headless
...with remote debugging enabled. See the python way in the question above or do it from the command line with the same arguments
5.2 Start a second instance of chrome
...using a different user data dir --user-data-dir=<some-path>
5.3 Navigate to http://192.168.1.194:9222
Use whatever the IP address of the first chrome instance is and the port that you chose.
5.4 Create a link to the local dev server
The 2nd instance of chrome will now be showing you links to debug each of the open tabs of the 1st instance. However the links will still to go https://chrome-devtools-frontend.appspot.com/..... You'll need to copy n paste the link you want and replace the hostname with the hostname of the devtools frontend that you started in step 4
Walla!!
If you figure out how to get the screencast working please comment below! 🙏
N.B:
I also tried using the npm run server command in the devtools frontend but for some reason that server didn't work at all ¯\_(ツ)_/¯
I would like to clarify something, when I say open cmd, I mean literally/physically open the cmd on the windows server. For example, if I use RDP to connect to the server then I can see the cmd open on the display.
I have used ssh to connect to a remote server then executed a script but it only executes this script in the background, I have not found a way to literally display the cmd running the script. I am trying to start my selenium grid remotely but IE instance cannot start the test unless the command prompt running the selenium node is displayed. I have found chrome can handle the situation fine, it will run the test on a hidden display. However, IE cannot do the same.
I have a GoCD server that I plan on running my selenium test suite on. This machine is a Linux machine. So.. I set up selenium on a windows machine. The key problem I am having is that when running as a service, or a scheduled task, the selenium hub does not launch IE.
If I remote desktop into the machine, run the jar manually from command line, the browser launches in my RDP session and the tests all pass. If I install it as a service (With permissions to interact with the desktop!) the driver appears to run, but the content never loads.
So if you have an answer, please remember:
The grid works for all browsers with an interactive desktop session open.
Without an interactive desktop session, Chrome and Firefox tests still pass (in headless mode).
I am using no selenium nodes, I am only using the standalone jar (not running as hub or node, just running the tests standalone.
I am using version 3.14 of both selenium standalone and IEDriverServer.exe
I know that tons of people do automated IE tests with selenium, but how do they do it with Hub on windows?
I've tried literally every options setting I can see to try to phinigel a way to get it to work, but it's just not having it.
I also tried running as a scheduled task rather than a service, no dice there either.
This is the precise error the IETests are presenting:
Oct 09, 2018 1:15:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for value to contain "sign-in.host.com". Current value: "null" (tried for 10 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:113)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:283)
I used to have issues with IE selenium tests on a VM in azure. What i noticed was that while RDP to the machine everything worked fine but when i closed the session all tests failed.
What i ended up doing was leaving a logged in console session after every RDP closing.
After adding a trigger on session log off i run a powershell script with the following:
Tscon 1 /dest:console
This keeps an active desktop session and my tests on IE pass.