Using intern js how to configure selenium grid without localhost proxy - selenium-grid

I am writing functional test case using intern.js. I wanted to run my test case in selenium grid which is already configured. I changed tunnel: 'NullTunnel' and webdriver: {
host:'',
port: 4444
}
In the intern configuration file and tried to execute my test case. I expect my testcase to be run on grid-config. But the intern is not running the testcase instead throws following error.
FATAL ERROR
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED
Error: connect ECONNREFUSED
at errnoException
at Object.afterConnect [as oncomplete]
Note: I did not run 'java -jar selenium-server-standalone-2.xx.x.jar -hub http://hub-server:4444/grid/register' command because I don't want to use my local machine as proxy.
But I want intern-runner to run the testcase directly through selenium grid.
Please help me on how to configure this.
Thanks

I found the solution my self by adding tunnelOptions in the config with host and port information of the grid.
Thanks

Related

WebDriver IO fails to create chrome browser sessions when using in Botium

I have installed Botium-Binding and prepared my machine to have installed with selenium-standalone server as per the documentation in https://github.com/codeforequity-at/botium-connector-webdriverio.
Once everything is setup i have added below capabilites to the botium.json file in samples/custom scripts folder.
"WEBDRIVERIO_OPTIONS": {
"capabilities": {
"browserName": "chrome",
}
}
Then i have run the command npm install && npm run mocha to trigger the runner.
All i could see is that the Webdriver session is being created and terminated with the error below:
WebdriverIO Plugin Sample
Starting ChromeDriver 92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515#{#1634}) on port 44325
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
1) "before each" hook for "contractcancellation"
0 passing (9s)
1 failing
1) WebdriverIO Plugin Sample
"before each" hook for "contractcancellation":
Error: WebDriver error on startup: Failed to create session.
Make sure to connect to valid hostname:port or the port is not in use.
If you use a grid server
Make sure to add vendor prefix like "goog:", "appium:", "moz:", etc to non W3C capabilities.
See more https://www.w3.org/TR/webdriver/#capabilities
tried adding Hostname, port, platform to the capabilities but of no use. Looking for some help on this to get me unblocked.
You have to follow the instructions to install a chromedriver version that matches your Chrome version (as pcalkins wrote above).
It this doesnt help I recommend to enable verbose logging to get more insights on whats happening. You may post the log output here for further investigation.

Host header or origin header is specified and is not localhost for selenium grid

I am trying to set up a selenium grid using the latest chrome and chromedriver. I get the following error when trying to run a test
Message: OpenQA.Selenium.WebDriverException : Unexpected error. Host header or origin header is specified and is not localhost.
On the node machine, I see the chrome browser open, but then it immediately closes and I get this error:
[1557513678.682][SEVERE]: Rejecting request with host: <hub_IP_address>:4444
Has anyone had this issue using the selenium grid? I am using:
selenium-server-standalone-4.0.0-alpha-1.jar and
Chromedriver 74.0.3729.6 for windows
My Chrome browser was running v.74.0.3729.108
JDK 12.0.1.0
Here is my command for starting the hub:
java -jar selenium-server-standalone-4.0.0-alpha-1.jar -role hub -hubConfig config.json
Here is my command to start a node:
java -Dwebdriver.chrome.driver="C:\...\Browsers\ChromeDirectory\chromedriver.exe" -Dwebdriver.ie.driver="C:\...\Browsers\IEDirectory\x86\IEDriverServer.exe" -jar -Dwebdriver.edge.driver="C:\...\Browsers\Edge\MicrosoftWebDriver.exe" -jar "C:\...\selenium-server-standalone-4.0.0-alpha-1.jar" -role node -hub "http://<hub_IP_address>:4444/grid/register/" -nodeConfig "C:\...\config.json"
I tried using a "host" property in the config.jsons. I tried putting the actual IP address and just localhost. But the hub and the node are obviously different machines, so putting localhost makes it so they can't connect. But when I dont have localhost, it says it needs to be specified as localhost? I'm so confused!! What is supposed to go in the host property?
I have seen people talk about a loopback property for protractor but I am not using protractor. I tried putting "loopback":true into both my node and hub config.json files but it doesn't seem to make a difference.
UPDATE:
I was able to get the grid to run successfully using the 4.0 alpha jar for the hub, and the old 3.8 jars for the nodes. All Still on Java 8. Kind of interesting.
You can try to add these switches: --whitelisted-ips --allowed-origins=''*
Try to run your node with command:
java -Dwebdriver.chrome.driver="C:\...\Browsers\ChromeDirectory\chromedriver.exe --whitelisted-ips --allowed-origins='*'" -Dwebdriver.ie.driver="C:\...\Browsers\IEDirectory\x86\IEDriverServer.exe" -jar -Dwebdriver.edge.driver="C:\...\Browsers\Edge\MicrosoftWebDriver.exe" -jar "C:\...\selenium-server-standalone-4.0.0-alpha-1.jar" -role node -hub "http://<hub_IP_address>:4444/grid/register/" -nodeConfig "C:\...\config.json"
I was able to get the selenium grid working by downgrading to 3.8.1 selenium grid jar and installing JDK 8 instead of 12. The reason I needed to get java 8 is answered in this other question. I used the same chrome driver and start up commands

Web Driver Curl Exception

Trying to use Codeception Web Driver and Selenium to emulate ajax through an acceptance test. I was using PhpBrowser but when I was having issues with Ajax my friend suggested WebDriver.
After enabling it and downloading the selenium (and running it) I get the following error.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session
with params: {"desiredCapabilities":{"browserName":"googlechrome"}}
Failed to connect to 127.0.0.1 port 4444: Connection Refused
I made sure I was running selenium on port 4444.
java -jar selenium-server.jar -port 4444
acceptance.suite.yml below
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- REST
config:
WebDriver:
url: 'http://life1605.dev'
browser: googlechrome
REST:
url: 'http://life1605.dev'
I had the same problem, with the exact same error message. For some strange reason, it looked like starting the selenium server from command line did not work.
My solution turned out to be manually opening the selenium server through Windows Explorer, right click on the file, choose Open with -> Java Platform SE Binary.
Took me almost 3 hours to figure it out, so I hope this helps somebody.
I had this problem and it turned out a new version of Firefox was incompatible with the addon that Selenium uses to communicate with Firefox.
When you start your tests you should see the new Firefox window appear, and have 30 seconds or so before it goes away again. Within this time, if you type about:addons into the URL field and then click on "Extensions", you should see the "Firefox WebDriver" addon there, and it should be enabled.
For me it was disabled as it was incompatible with the latest Firefox version. So the solution in this case was to either downgrade Firefox or wait for an updated Selenium.
Note that the addon is only installed in the Firefox instance under test, so you won't see it when you use Firefox outside of Selenium.
I had this same problem, I forgot to run phantom.js before trying to do any browser tests. I ran phantomjs and it worked.
I had this problem, and then I remembered that I need to run Xvfb -ac :0 -screen 0 1280x1024x16 & after every Homestead reload (before running Dusk tests).
Then Dusk works instead of saying:
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown
for http POST to /session with params:
{"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Operation timed out after 30000 milliseconds with 0 bytes received
See https://stackoverflow.com/a/42630737/470749

Error: cannot open display: :0 for Selenium tests

Firstly I was getting the following error:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
So I have used export DISPLAY=:0 to circumvent this problem. Followed to that I have found Selenium tests were running using the root user and all was fine.
However now I can see when these tests are getting executed from Jenkins the following error is coming up:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
No protocol specified
Error: cannot open display: :0
I am running this on a Redhat 6 box.
You can download the Jenkins xvnc plugin and make that plugin start(and export) a virtual display for selenium to use.
The jenkins user may not have access to the :0 display.
The best approach to solve this problem is making changes to the jenkins start script.
The solution that works on Ubuntu for me correctly is as follows:
1.Open Jenkins shell script located at: /etc/init.d/jenkins.
2.Add the following lines as follows before PATH variable:
/usr/bin/X :0 vt7 -ac
export DISPLAY=:0
xhost +

Selenium - When running builds via the grid, how do you get the console output?

We've been running Selenium tests via local RC for a few years, and are starting to migrate to the grid. We have been redirecting the console output of the server to our own test logs. It is quite useful for debugging. The console output looks suspiciously like Log4J - so it should be reconfigurable.
10:31:51.894 INFO - Command request: open[http://websiteundertest/IsSiteUpUp.aspx, ] on session 46c211b412474429957dbf6bebccd64d
10:31:55.323 INFO - Got result: OK on session 46c211b412474429957dbf6bebccd64d
10:31:56.330 INFO - Command request: isElementPresent[xpath=//h2, ] on session 46c211b412474429957dbf6bebccd64d
10:31:56.343 INFO - Got result: OK,true on session 46c211b412474429957dbf6bebccd64d
When re run via the hub, the console output appears only on the remote RC. The simple console redirection won't work. In scope of this question, we need to capture the remote console output someplace where the computer executing the test can get to it. We run our tests from a number of build agents via C#. We are trying grid 1 and 2. We intend to go directly to Grid 2.x.
What he meant was that this:
java -jar selenium-server-standalone-2.15.0.jar -role webdriver -hub http://127.0.0.1:4444/grid/register > mylog.txt
does not work. It will create a new file but it will be empty. I suggest using -log mylog.txt
argument when starting node or server to store log files
In the latest version of Grid, you can redirect the output when you start each of your client nodes:
java -jar selenium-server-standalone-2.15.0.jar -role webdriver -hub http://127.0.0.1:4444/grid/register > mylog.txt
This is a Windows example. You can also centralize log files on some remote server by referencing a \\serverName\mylog.txt in your redirect.
When you say:
The simple console redirection won't work...
I'm not sure I understand.