Results 1 to 4 of 4

Thread: Switch to another browser tab

  1. #1
    Sencha User
    Join Date
    Sep 2017
    Posts
    9
    Vote Rating
    0
      0  

    Default Switch to another browser tab

    Hi everyone! Hope I'm posting this in the right place.

    I have a Jasmine Test Suite on Sencha Test, where I click a link, and I want to verify that the page was successfully opened. It opens in a new tab, so I need the driver to switch to that tab before checking some elements.

    I used to do something like this when working with jUnit and always worked fine for me:

    WebUtil.click(driver, By.id("analyticsmenu"));
    ArrayList<String> tabs2 = new ArrayList<String> (driver.getWindowHandles());
    driver.switchTo().window(tabs2.get(1));

    I'm trying to do something similar on my Sencha Test suite, but no success. It says the functions don't exist for driver, so I tried with the ST.system

    var tabs2 = [(ST.system.getWindowHandles())];
    ST.system.switchTo().window(tabs2[1]);

    This gives me an error saying that the switchTo function is undefined. I tried with ST.defaultContext.driver.switchTo as well and didn't work. By using the debugger I could see that the tabs2 is not getting any values to start with. Any ideas? Thanks for the attention!

  2. #2
    Sencha - Support Team joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    443
    Vote Rating
    184
      0  

    Default

    Hi--

    The default context uses webdriverio behind the scenes, so you might try swithTab() instead:
    http://webdriver.io/api/window/switchTab.html

    Thanks
    Joel

  3. #3
    Sencha User
    Join Date
    Sep 2017
    Posts
    9
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by joel.watson View Post
    Hi--

    The default context uses webdriverio behind the scenes, so you might try swithTab() instead:
    http://webdriver.io/api/window/switchTab.html

    Thanks
    Joel
    Hi Joel!

    Thanks for the reply.

    So, what I have now is:

    MyPageObject.menuLink()
    .click();

    var tabs2 = [(ST.defaultContext.driver.windowHandles())];
    ST.defaultContext.driver.switchTab(tabs2[1]);

    This changes the focus to the new tab just fine, but if after that line I make a newTabComponent.click() then it won't find the component. It's almost like the browser is changing the focus but not the target of the test (not sure if I'm putting with proper terms). Even that I use the Inspector, when I click something in this page of the new tab, nothing shows in the component list.
    If I navigate directly to the link of the new tab, without accessing it through the menu, then it recognize all these same components and clicks it just fine.

  4. #4
    Sencha - Support Team joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    443
    Vote Rating
    184
      0  

    Default

    Ah, right, the ST API will still only exist in the original context. Once you switch tabs, you'll probably have to rely on the webdriver.io APIs to interact with elements on the new context. We have plans to support this better in the future, but currently it's not something directly supported.

Similar Threads

  1. Replies: 3
    Last Post: 22 Mar 2013, 11:32 AM
  2. Replies: 1
    Last Post: 1 Aug 2012, 12:17 AM
  3. Replies: 0
    Last Post: 20 Feb 2010, 1:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •