Skip to content

Commit

Permalink
Fixing element not found for iPhone (#3487)
Browse files Browse the repository at this point in the history
## Proposed changes

[//]: # (Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.)
1.) Adding a match for the errors thrown by iphone/appium so that isExisting/isDisplayed/waitForExist/waitForDisplayed will work

## Types of changes

[//]: # (What types of changes does your code introduce to WebdriverIO?)
[//]: # (_Put an `x` in the boxes that apply_)

- [X] 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

[//]: # (_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._)

- [ ] I have read the [CONTRIBUTING](https://github.com/webdriverio/webdriverio/blob/master/CONTRIBUTING.md) 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

[//]: # (If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...)

### Reviewers: @webdriverio/technical-committee
  • Loading branch information
abjerstedt authored and christian-bromann committed Feb 2, 2019
1 parent 0b38899 commit a7868c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/webdriver/src/utils.js
Expand Up @@ -28,7 +28,11 @@ export function isSuccessfulResponse (statusCode, body) {
/**
* ignore failing element request to enable lazy loading capability
*/
if (body.status && body.status === 7 && body.value.message && body.value.message.startsWith('no such element')) {
if (body.status && body.status === 7 && body.value.message &&
(body.value.message.startsWith('no such element') ||
//Appium
body.value.message ===
'An element could not be located on the page using the given search parameters.')) {
return true
}

Expand Down
3 changes: 3 additions & 0 deletions packages/webdriver/tests/utils.test.js
Expand Up @@ -14,6 +14,9 @@ describe('utils', () => {
expect(isSuccessfulResponse(200, { value: { some: 'result' } })).toBe(true)
expect(isSuccessfulResponse(404, { value: { error: new Error('foobar' )} })).toBe(false)
expect(isSuccessfulResponse(404, { value: { error: 'no such element' } })).toBe(true)
expect(isSuccessfulResponse(404, { value: {
message: 'An element could not be located on the page using the given search parameters.'}
})).toBe(true)
expect(isSuccessfulResponse(200, { status: 7 })).toBe(false)
expect(isSuccessfulResponse(undefined, { status: 7, value: {} })).toBe(false)
expect(isSuccessfulResponse(undefined, { status: 0, value: {} })).toBe(true)
Expand Down

0 comments on commit a7868c8

Please sign in to comment.