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

.frame() does not change focus to browser top-level default context #2047

Closed
liunate opened this issue Mar 8, 2019 · 3 comments
Closed

.frame() does not change focus to browser top-level default context #2047

liunate opened this issue Mar 8, 2019 · 3 comments

Comments

@liunate
Copy link
Contributor

liunate commented Mar 8, 2019

What the issue is

Either .frame() or .frame(undefined) or .frame(null) is supposed to switch browser context to default top-level one but receives missing 'id' or no such frame error with or without selenium server.

The line

switchToFrame(frameId) {
should POST with { id: null } in request body given either .frame arguments listed above per W3C spec https://www.w3.org/TR/webdriver/#switch-to-frame:

  1. Let id be the result of getting the property "id" from the parameters argument.
  2. If id is not null, a Number object, or an Object that represents a web element, return error with error code no such frame.

Simple test showing the issue:

Repo
https://github.com/liunate/nightwatch-issue-frame-missing-id

Nightwatch Config

{
  "src_folders": [
    "tests"
  ],
  "webdriver": {
    "start_process": true,
    "server_path": "node_modules/.bin/chromedriver",
    "port": 9515
  },
  "test_settings": {
    "default": {
      "launch_url": "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe",
      "silent": false,
      "screenshots": {
        "enabled"    : true,
        "on_failure" : true,
        "on_error"   : true,
        "path"       : "tests_output/screenshots"
      },
      "globals": {
        "abortOnAssertionFailure": false
      },
      "desiredCapabilities": {
        "browserName": "chrome"
      }
    }
  }
}

Test Case

  showMissingIdError: (client) => {
    
    const elementOutSideOfIFrame = '#Result_2'; // Title 'Result' just above iframe element on page
    
    const iframeId = 'frame_Example2';
    const deeperIframeId = 'Example2';
    const elementWithinIFrame = '#mapDiv';
    
    client.
      url(client.launch_url).
      waitForElementVisible(elementOutSideOfIFrame).
      frame(iframeId).
      frame(deeperIframeId).
      waitForElementVisible(elementWithinIFrame). 
      frame(null). // Error while running .switchToFrame() protocol action: invalid argument: missing 'id'
      frame(). // Error while running .switchToFrame() protocol action: invalid argument: missing 'id'
      waitForElementVisible(elementOutSideOfIFrame).
      waitForElementNotVisible(elementWithinIFrame);
  }

Verbose nightwatch output

  Running command: frame ()
   Request POST  /session/3e9e8d20ed874049d3ff2f79b3988324/frame  
   { id: 'null' }
   Response 200 POST /session/3e9e8d20ed874049d3ff2f79b3988324/frame (6ms)
   { sessionId: '3e9e8d20ed874049d3ff2f79b3988324',
     status: 8,
     value: 
      { message: 'no such frame',
        error: 
         [ '  (Session info: chrome=72.0.3626.121)',
           '  (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.1 x86_64)' ] } }
 Error while running .switchToFrame() protocol action: no such frame

  Completed command frame () (6ms)
  Running command: frame ()
   Request POST  /session/3e9e8d20ed874049d3ff2f79b3988324/frame  

   Response 200 POST /session/3e9e8d20ed874049d3ff2f79b3988324/frame (4ms)
   { sessionId: '3e9e8d20ed874049d3ff2f79b3988324',
     status: 61,
     value: 
      { message: 'invalid argument: missing \'id\'',
        error: 
         [ '  (Session info: chrome=72.0.3626.121)',
           '  (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.1 x86_64)' ] } }
 Error while running .switchToFrame() protocol action: invalid argument: missing 'id'

  Completed command frame () (8ms)

versions

nightwatch 1.0.19
chrome=72.0.3626.121
chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.1 x86_64)
macOS Majove 10.14.1 (18B75)
Node v8.11.2
Selenium not used

liunate added a commit to liunate/nightwatch that referenced this issue Mar 8, 2019
@liunate
Copy link
Contributor Author

liunate commented Mar 12, 2019

PR #2048 is sent to correct the behavior.

@VasylQA
Copy link

VasylQA commented Apr 12, 2019

I'm having the same issue after update to 1.0.19 version

@joshden
Copy link

joshden commented Apr 17, 2019

Thanks @liunate. For now I'm installing Nightwatch NPM with git+https://github.com/nightwatchjs/nightwatch.git#612ae4b4388e1221704b2e3908547c0178bdc5ec to have this fix where I'm testing upgrading my tests to use Nightwatch 1.x.x. Hopefully it will be merged and included in a build soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants