https://github.com/nightwatchjs/nightwatch/blob/master/lib/page-object/element.js#L17
In this code we are used css selector. Maybe it's should be use global configuration?
Yeah, it should use xpath if use_xpath is true in nightwatch.json - http://nightwatchjs.org/guide#using-xpath-selectors. Or are you suggesting we add support for using any locate strategy? I think using anything other than 'css selector' or 'xpath' is quite an edge case so that wasn't a concern so far.
@beatfactor
I hope that we can define selector strategy on atom operations like that:
browser/somePageObject.click({select: '//xxx', strategy: 'xpath'})
As you can see, switching strategy in page object custom command is to painful, it would be find if you could find some easier ways
@lcjnil I'm working on something very similar to that. See #1116.
+1
I defined "use_xpath": true in my test_setting in nightwatch.json, still the default behaviour is css, it wouldn't change as specified in the guide:
"To always use xpath by default set the property "use_xpath": true in your test settings."
http://nightwatchjs.org/guide#using-xpath-selectors
I have the same issue as @karthikkbaalaji where even if I define "use_xpath": true the default behaviour is css
+1
+1
+21(21 testers on our side.)
This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.
I'm also seeing my "use_xpath" value being ignored. Am I doing something wrong?
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000, // sometimes internet is slow so wait.
"use_xpath": true
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // turn off to test progressive enhancement
}
}
}
This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.
Not sure why this was closed because it's still an issue in Nightwatch v1.5
Most helpful comment
+1
I defined "use_xpath": true in my test_setting in nightwatch.json, still the default behaviour is css, it wouldn't change as specified in the guide:
"To always use xpath by default set the property "use_xpath": true in your test settings."
http://nightwatchjs.org/guide#using-xpath-selectors