New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't fail element command in IE #3874
Conversation
Nice! Thanks @christian-bromann |
body.value.message === | ||
'An element could not be located on the page using the given search parameters.')) { | ||
if ( | ||
body.status === 7 && body.value && body.value.message && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is body.status
always defined? Any reason for removing the first if check on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if status is undefined the assertion will fail, no need to check whether status exists or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI:
on Edge and Safari the response body does not have a 'status':
{
value: {
stacktrace: 'org.openqa.selenium.NoSuchElementException: The specified element was not found in the current fra
me or window.(WARNING: The server did not provide any stacktrace information)\ nCommand duration or timeout: 0 millis
econds\ nFor documentation on this error,
please visit: http: //seleniumhq.org/exceptions/no_such_element.html\nBuild i
nfo: version: \'3.14.0\', revision: \'aacccce0\', time: \'2018-08-02T20:13:22.693Z\'\nSystem info: host: \'SAUCE-WIN1
0\ ', ip: \'172.20.59.68\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_1
31\ '\nDriver info: driver.version: unknown\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Meth
od)\ r\ n\ tat sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)\ r\ n\ tat sun.reflect.DelegatingConst
ructorAccessorImpl.newInstance(Unknown Source)\ r\ n\ tat java.lang.reflect.Constructor.newInstance(Unknown Source)\ r\ n\
tat org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java: 214)\ r\ n\ tat org.openqa.selenium.remote
.ErrorHandler.throwIfResponseFailed(ErrorHandler.java: 166)\ r\ n\ tat org.openqa.selenium.remote.http.JsonHttpResponseCo
dec.reconstructValue(JsonHttpResponseCodec.java: 40)\ r\ n\ tat org.openqa.selenium.remote.http.AbstractHttpResponseCodec
.decode(AbstractHttpResponseCodec.java: 80)\ r\ n\ tat org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(A bstractHttpResponseCodec.java: 44)\ r\ n\ tat org.openqa.selenium.remote.server.ProtocolConverter.handle(ProtocolConverte r.java: 87)\ r\ n\ tat org.openqa.selenium.remote.server.RemoteSession.execute(RemoteSession.java: 127)\ r\ n\ tat org.openqa
.selenium.remote.server.WebDriverServlet.lambda$handle$3(WebDriverServlet.java: 250)\ r\ n\ tat java.util.concurrent.Exec
utors$RunnableAdapter.call(Unknown Source)\ r\ n\ tat java.util.concurrent.FutureTask.run(Unknown Source)\ r\ n\ tat java.u
til.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\ r\ n\ tat java.util.concurrent.ThreadPoolExecutor$Worker.ru
n(Unknown Source)\ r\ n\ tat java.lang.Thread.run(Unknown Source)\ r\ n ',
message: 'The specified element was not found in the current frame or window. (WARNING: The server did not prov
ide any stacktrace information)\ nCommand duration or timeout: 0 milliseconds\ nFor documentation on this error, please
visit: http: //seleniumhq.org/exceptions/no_such_element.html\nBuild info: version: \'3.14.0\', revision: \'aacccce0\
', time: \'2018-08-02T20:13:22.693Z\'\nSystem info: host: \'SAUCE-WIN10\', ip: \'172.20.59.68\', os.name: \'Windows 1
0\ ', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_131\'\nDriver info: driver.version: unknown',
error: 'no such element'
}
}
so we may need to do something like:
/**
* ignore failing element request to enable lazy loading capability
*/
if (
body.status === 7 && body.value && body.value.message &&
// body.value && body.value.message &&
(
body.value.message.toLowerCase().startsWith('no such element') ||
// Appium
body.value.message === 'An element could not be located on the page using the given search parameters.' ||
// Internet Explorter
body.value.message.toLowerCase().startsWith('unable to find element')
)
) {
console.log(body)
return true
}
else if (body.value && body.value.message &&
// Edge
(
body.value.message.toLowerCase().startsWith('the specified element was not found') ||
// Safari
body.value.message.toLowerCase().startsWith('an element could not be located on the page')
)
) {
console.log(body)
return true
}
but not sure if that will break when an actual element is not there that we expect to bet etc?
Codecov Report
@@ Coverage Diff @@
## master #3874 +/- ##
=======================================
Coverage 98.57% 98.57%
=======================================
Files 153 153
Lines 3434 3434
Branches 750 750
=======================================
Hits 3385 3385
Misses 44 44
Partials 5 5
Continue to review full report at Codecov.
|
61f7cca
to
9488d6e
Compare
rebase on master, any outstanding comments or is it good to go? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
FYI: on Edge and Safari the response body does not have a 'status':
so we may need to do something like:
but not sure if that will break when an actual element is not there that we expect to bet etc? |
Proposed changes
Change the
isSuccessfulResponse
utility to return successful response in case I can't find the element.Types of changes
Checklist
Further comments
Reviewers: @webdriverio/technical-committee