Reputation: 1659
I have problem when run test on Android. Is look like click action not work, but works fine on iPhone and in Chrome on desktop (Windows). I use CodeceptJS 1.1.0, WebDriverIO 4.9.9, Selenium-stanalone 6.11.0 and BrowserStack 1.5.0
BrowserStack configuration:
exports.config = {
tests: ******,
timeout: 10000,
output: './output',
helpers: {
WebDriverIO: {
user: ******,
key: ******,
url: ******,
smartWait: 5000,
browser: 'Android',
commonCapabilities: [{
'browserstack.debug': true,
'browserstack.video': false
}],
},
MyHelper: {
require: "./MyHelper.js"
}
},
include: {
I: './hosts/helper.js'
},
bootstrap: false,
mocha: {},
name: 'js'
};
Logs for iPhone:
• I am on page "/"
• I see element "#registerMultiStepContainer"
• I see element "#registration-step-1 .next"
• I click "#registration-step-1 .next"
WARNING: the "touchClick" command will be deprecated soon. If you have further questions, reach out in the WebdriverIO Gitter support channel (https://gitter.im/webdriverio/webdriverio).
Note: This command is not part of the W3C WebDriver spec and won't be supported in future versions of the driver. It is recommended to use the touchAction command for this.
(You can disable this warning by setting `"deprecationWarnings": false` in your WebdriverIO config)
• I wait 5
• I see element "#registration-step-2"
✓ OK in 15109ms
Logs for Android:
• I am on page "/"
• I see element "#registerMultiStepContainer"
• I see element "#registration-step-1 .next"
• I click "#registration-step-1 .next"
WARNING: the "touchClick" command will be deprecated soon. If you have further questions, reach out in the WebdriverIO Gitter support channel (https://gitter.im/webdriverio/webdriverio).
Note: This command is not part of the W3C WebDriver spec and won't be supported in future versions of the driver. It is recommended to use the touchAction command for this.
(You can disable this warning by setting `"deprecationWarnings": false` in your WebdriverIO config)
• I wait 5
• I see element "#registration-step-2"
✖ FAILED in 17435ms
-- FAILURES:
1) Login test: Login as testuser:
expected elements of #registration-step-2 to be seen
+ expected - actual
-false
+true
I try with my custom step to make alternative for click
and instead of using Webdriver touchClick
, use something else, but then I got:
Not yet implemented. Please help us: http://appium.io/get-involved.html
Can someone give me any information what can be problem and what is the problem between Webdriver
and Appium
?
EDIT
Code of test:
I.amOnPage('/');
I.seeElement('#registerMultiStepContainer');
I.seeElement('#registration-step-1 .next');
I.wait(5); // working same with and without this step
I.click('#registration-step-1 .next');
I.wait(5);
I.seeElement('#registration-step-2');
My custom step:
tap(selector) {
let browser = this.helpers['WebDriverIO'].browser;
return browser.touchPerform([{
action: 'tap',
options: {
element: selector,
x: 5,
y: 5,
count: 1
}
}]);
}
Also try this and similar:
tap(selector) {
return this.helpers['WebDriverIO'].browser.touchAction(selector, 'tap');
}
Upvotes: 1
Views: 1485
Reputation: 1659
I still do not know what is the problem, Selenium/Webdriver/Browserstack incompatibility or wrong settings or some bug on Browserstack, but I fix this with simulation click event in my custom step.
If someone have better approach, please, let me know. Thanks.
module.exports = class MyHelper extends codecept_helper {
_before() {
let browser = this.helpers['WebDriverIO'].browser;
browser.addCommand('jsClick', function(selector, cb) {
browser.execute(function(cssSelector) {
var clickEvent = document.createEvent("MouseEvent");
clickEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.querySelector(cssSelector).dispatchEvent(clickEvent);
}, selector, cb);
});
}
jsClick(selector) {
return this.helpers['WebDriverIO'].browser.jsClick(selector);
}
}
Upvotes: 2