Skip to content
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

Merged
merged 1 commit into from Apr 23, 2019

Conversation

christian-bromann
Copy link
Member

Proposed changes

Change the isSuccessfulResponse utility to return successful response in case I can't find the element.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Reviewers: @webdriverio/technical-committee

@pmerwin
Copy link
Contributor

pmerwin commented Apr 23, 2019

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 &&
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Contributor

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?

@mgrybyk mgrybyk closed this Apr 23, 2019
@mgrybyk mgrybyk reopened this Apr 23, 2019
@codecov
Copy link

codecov bot commented Apr 23, 2019

Codecov Report

Merging #3874 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           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
Impacted Files Coverage Δ
packages/webdriver/src/utils.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d006047...9488d6e. Read the comment docs.

@christian-bromann
Copy link
Member Author

rebase on master, any outstanding comments or is it good to go?

Copy link
Member

@WillBrock WillBrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@christian-bromann christian-bromann merged commit 57f3e8e into master Apr 23, 2019
@christian-bromann christian-bromann deleted the cb-fix-element-response-ie branch April 23, 2019 21:06
abjerstedt pushed a commit that referenced this pull request Apr 26, 2019
@pmerwin
Copy link
Contributor

pmerwin commented Apr 29, 2019

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?

yamkay pushed a commit to MoveInc/webdriverio that referenced this pull request Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix 🐛 PRs that contain bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants