Skip to content

Instantly share code, notes, and snippets.

@DanielGallo
Last active September 26, 2019 22:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielGallo/7193f9d8059ec820373f9c0750bebd42 to your computer and use it in GitHub Desktop.
Save DanielGallo/7193f9d8059ec820373f9c0750bebd42 to your computer and use it in GitHub Desktop.
Shows how to handle and switch multiple tabs in Sencha Test
// WebDriver scenario URL: https://examples.sencha.com/extjs/6.7.0/examples/kitchensink/frame-index.html#link-buttons
describe('Switching tabs', function() {
var tabIds, driver;
beforeAll(function() {
// This stores a reference to the underlying driver object
driver = ST.defaultContext.driver;
});
it('should click a button that opens a second tab', function() {
ST.button('contentPanel button[text="Medium"]:first')
.click();
});
it('should fetch all open browser tabs', function(done) {
driver.getTabIds()
.then(function(tabs) {
tabIds = tabs;
done();
});
});
it('should switch tabs to second tab', function() {
driver.switchTab(tabIds[1]).then(function() {
// Check definitely referencing correct page
ST.getUrl(function(url) {
expect(url).toContain('www.sencha.com');
});
});
});
it('should do something in the other tab', function() {
ST.element('.site-title')
.visible();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment