Open richardjimenez52 opened 1 year ago
Hey @richardjimenez52 It throws an error because Nightwatch
communicates directly with WebDrivers
in the case of elemet expect assertion
commands, which requests required a port that was never assigned. It is because safaridriver's default port value is 0
and 0
is considered false by Javascript in if
statements.
So can you try the following configuration ?
'ios.simulator.safari': {
launch_url: "http://localhost:4200/smoke",
skip_testcases_on_fail: false,
desiredCapabilities: {
browserName: 'safari',
platformName: 'iOS',
'safari:useSimulator': true,
// change the deviceName, platformVersion accordingly to run tests on
// Run command: `xcrun simctl list devices`
// 'safari:platformVersion': '15.0',
'safari:deviceName': 'iPhone 8'
},
webdriver: {
start_process: true,
server_path: '',
host: '127.0.0.1',
port: 4444,
cli_args: [
// very verbose geckodriver logs
// '-vv'
]
}
},
Hi @harshit-bs , after adding those changes to the webdriver object, now the simulator doesn't even spin up the device. I am manually able to spin up the device by running open -a simulator
but not through nightwatch. I added --verbose
and here is the log
this is my new configuration:
'ios.simulator.safari': {
globals:{
env: "ios"
},
launch_url: "http://localhost:4200/smoke",
skip_testcases_on_fail: false,
desiredCapabilities: {
javascriptEnabled: true,
acceptInsecureCerts: true,
real_mobile: false,
browserName: 'safari',
platformName: 'iOS',
//platformVersion: '15.0',
'safari:useSimulator': true,
// change the deviceName, platformVersion accordingly to run tests on
// Run command: `xcrun simctl list devices`
// 'safari:platformVersion': '15.0',
'safari:deviceName': 'iPhone X'
},
webdriver: {
start_process: true,
host: '127.0.0.1',
port: 4444,
server_path: '',
cli_args: [
// --verbose
]
}
},
It seems strange. Perhaps we're overlooking something. I have created a sample repository incorporating the information you shared. Would you mind testing it and letting me know the outcome?
Hi @harshit-bs apologies for the late reply. I can't seem to be able to run test example on the repo you created. I'm getting an error with safari driver?
Description of the bug/issue
When running nightwatch tests against an ios simulator I get failures when trying to the following command'
browser.expect.element(inputElement).to.have.attribute('value').to.equal('Item 1');
The IOS simulator is from the package nightwatchjs/mobile-helper-tool
I'm running tests against a local enviornment on port 4200 yet the error I get when it gets to my assertions is: Error while running .getElementAttribute() protocol action: Error ECONNREFUSED: connect ECONNREFUSED 127.0.0.1:80
The browser steps before that test such as .click, .waitForElementPresent work as expected. If i pause the tests and inspect the element it indeed has the correct value i'm trying to assert yet it fails on ios simulator but passes when being ran against regular desktop browser.
Steps to reproduce
No response
Sample test
Command to run
Verbose Output
Nightwatch Configuration
Nightwatch.js Version
^2.6.10
Node Version
v16.13.2
Browser
safari
Operating System
iphone 8
Additional Information
the ios simulator is from
@nightwatch/mobile-helper": "^0.1.8"