How to run feature files in Safari using WebDriverIO? - safari

I'm using WebDriverIO to automate a web page, I'm able to run my feature files in Chrome but I need them to run in Safari. I'm using a Mojave 10.14.6 device. I've allowed remote automation on safari, and enabled safaridriver from terminal.
My wdio.conf.js capabilities are look like this:
capabilities: [{
maxInstances: 5,
browserName: 'safari'
}]
When I run using chrome it works as spected but in the case of safari I get the following message:
ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4444
My package.json looks like this:
"dependencies": {
"#wdio/cli": "^7.5.7"
},
"devDependencies": {
"#wdio/cucumber-framework": "^7.5.3",
"#wdio/local-runner": "^7.5.7",
"#wdio/spec-reporter": "^7.5.7",
"chromedriver": "^90.0.0",
"wdio-chromedriver-service": "^7.0.0"
}
Is there any other configuration I need to add in wdio.conf.js file?
Thanks in advance.

It turns out to be a problem with the port that was being used. After the port was changed from 4444 to the correct value, the issue was solved.

Related

WebdriverIO setting browser language problem for headless chrome browser on linux server

I am using webdriverio for test automation and I am trying to change my chrome browser configurations via wdio.config.js file. I am running chrome headless browser and locally everything geos fine, but on the linux server it looks like the language setting doesn't take an effect.
An additional detail is that I have 2 jobs in the pipeline (1 for English and one for Netherlands language) but it seems both of them are running in English.
Here are my browser capabilities section:
{
maxInstances: 1,
browserName: 'chrome',
'goog:chromeOptions': {
args: [
'--headless',
'--disable-dev-shm-usage',
'--disable-gpu',
'--window-size=1920,1080',
'--disable-web-security',
'--lang=nl',
'ignore-certificate-errors'
],
},
}

Testcafe connects very slow to dev URL

I am trying to test a Dev URL using Testcafe framework in my corp network via proxy. it all worked fine when it was running locally. But when I initialized git into my project Testcafe browser start connecting to test URL very slow. it sounds weird but just wanted to check if any configuration impacts testcafe browser to connect to URL. While in Chrome I can connect to URL smoothly.
Monitored the network tab on testcafe browser and found some errors where it is trying to use static URLs and some javascript error. I tried
testcafe chrome tests/ --skip-js-errors --proxy eXXXXXX:8080
{
"name": "mXXXXuiautomation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "testcafe chrome tests/ --skip-js-errors --proxy eXXXXX:8080"
},
Using npm test to run my test
Expected: Testcafe browser should connect to URL in a smooth way with minimal execution time
Actual: It connects very slowly and some tests fail because an element is not found in the expected time

Launch chrome with extension using protractor

I'm trying to launch chrome browser with "Modheader" extension using protractor by using the following in my conf.js
chromeOptions: {
args: [
'--load-extension=C:/Utilities/extension_2_2_4_0.crx'
],
But on running the test I get the following error:
Failed to load extension from ..... Manifest file is missing or unreadable
Is there any way to launch the browser with extension already installed OR is there any way to provide header with URL using protractor
baseUrl= www.abc.com
Header= 'name' : 'testuser'

Selenium doesn't start webdriver

versions
"nightwatch": "^0.9.16"
"chromedriver": "^2.30.1"
"selenium-server-standalone-jar": "^3.4.0"
I'm using nightwatch but that sh
I also tried with
I'm using nightwatch to run Selenium in this repo and I've tried with chrome and firefox drivers, no luck on either.
I have selenium standalone and chromedriver packages, and I know the path is right on nightwatch.conf.js:
const jar = require('selenium-server-standalone-jar')
console.log(jar.path) // logs /home/goldylucks/apps/ci-workshop/node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.4.0.jar
const chromedriver = require('chromedriver')
console.log(chromedriver.path) // logs /home/goldylucks/apps/ci-workshop/node_modules/chromedriver/lib/chromedriver/chromedriver
'selenium': {
'start_process': true,
'server_path': jar.path,
'log_path': '',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.ie.driver': '',
},
},
'test_settings': {
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
},
},
yet when I run the test it times out and hangs:
$ yarn e2e:ui
yarn e2e:ui v0.24.6
$ nightwatch -e chrome
Starting selenium server... started - PID: 12936
[App E2e Ui] Test Suite
===========================
✖ Timed out while waiting for element <body> to be present for 5000 milliseconds. - expected "visible" but got: "not found"
at Object.before (/home/goldylucks/apps/ci-workshop/test/ui/app.e2e-ui.js:9:8)
I tried it with the following combinations:
1. with the express server which serves the app on another terminal
2. without the express server
3. each of the above with chromedriver manually started at another terminal (I really don't think it should matter and that I should do this, just wanted to be thorough ...)
running the chromedriver manually yields the following and hangs:
$ node_modules/chromedriver/lib/chromedriver/chromedriver
Starting ChromeDriver 2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5) on port 9515
Only local connections are allowed.
I also tried running with firefox and it didn't work, which leads me to believe the problem is deeper than the chromedriver, i.e. related to selenium interacting with nightwatch.
I recall this happening a while back. I think it was that a previous instance Selenium had not closed freed port 4444 when shutting down. Try shutting down selenium and restarting.
To do that, open the following webpage manually, in the browser of your choice.
http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer
Then try running the script again as normal.

Test browser code with Intern through Grunt and Phantomjs

I have been playing with Intern and made my tests work in the browser. To better integrate with my current workflow I'm trying to run my tests through grunt with phantomjs. However all my attempts have failed. I've been looking at this question as a reference Intern WebDriver and PhantomJS but can't figure out all of the steps to make it work.
First of all: Is it even possible to run the tests through grunt and phantomjs?
A little bit of info:
I don't want/can't connect to Sauce Labs or a Selenium testing environment.
I want to test browser code while having jQuery as a shimmed dependency
I have Grunt 0.4.1 and phantomjs 1.9.1 installed
I'm not testing any ajax request (as the linked question is having problem with)
I'm not familiar with neither Selenium nor Sauce Lab
If it is possible to test through grunt and phanomjs, how would I go about doing it?
I guess that I have to start the GhostDriver
phantomjs --webdriver=8910
But then what are the important pieces of info in the Intern config to make this work?
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
environments: [
{
browserName: 'phantom',
version: '1.9.0',
platform: 'Linux'
}
],
webdriver: {
host: 'localhost',
port: 8910
},
maxConcurrency: 3,
useSauceConnect: false,
// ...
});
How does the environments browserName map to phantomjs? I've tried the browserNames 'phantom' as well as 'phanomjs' with different versions and platforms (running Mac 10.7)
My Gruntfile section for intern looks like:
intern: {
phantom: {
options: {
config: 'tests/intern',
reporters: ['webdriver']
}
}
}
Running this setup without any test-suite that includes browser code outputs
'ReferenceError: document is not defined' in 'node_modules/intern/lib/reporters/webdriver.js:41:19'
Adding browser tests gives 'ReferenceError: window is not defined' in 'src/vendor/jquery/jquery-1.9.1.js:9597:5'
Running it through node gives the same 'window is not defined' error.
node node_modules/intern/client.js config=tests/intern
What am I doing wrong/missing here?
There are two problems with your Gruntfile configuration:
The default run type for the Grunt task is 'client', which means it runs the Node.js client by default, not the test runner. You need to set runType: 'runner' in your Gruntfile options to run tests against your specified environments.
The webdriver reporter is for use in a browser client only and is specified automatically by the test runner when it is needed. You should typically never use it directly. The reporter you specify in the Gruntfile should be the one you want the test runner to use; the console default is usually appropriate.
These two things in combination mean that you’ve configured Intern to try to use a reporter that only works in a browser in conjunction with the test runner inside the Node.js client, hence the error. Once corrected, the remaining configuration should work properly to run on PhantomJS, assuming it is already running on localhost at port 8910.