Skip to content

Instantly share code, notes, and snippets.

@DanielGallo
Last active Sep 26, 2019
Embed
What would you like to do?
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