JS-Window handling-SwitchTabs
- when you click on link it will open a new tab , to handle that suitation we use browser.switchTo().window(nameOrHandle).
browser.open(//);
element.getAllWindowHandlers().then(function(handlers){
//handlers- get the list of window
browser.switchto().window(handlers[1]);//child window
switchback to parent window
browser.switchto().window(handlers[0]);//Parent window
)
const { element, browser } = require("protractor");
describe('',function(){
it('',function(){
browser.waitForAngularEnabled(false);
browser.get('https://rahulshettyacademy.com/AutomationPractice/');
expect(browser.getTitle()).toBe('Practice Page');
browser.getTitle().then(function(text){
console.log(text);
});
element(by.id('opentab')).click().then(function(){
browser.sleep('3000');
})
browser.getAllWindowHandles().then(function(handlers){
browser.switchTo().window(handlers[1]);
browser.getTitle().then(function(texta){
console.log(texta);
});
})
browser.sleep(3000);
expect(browser.getTitle()).toBe('QAClick Academy - A Testing Academy to Learn, Earn and Shine');
})
})
Comments
Post a Comment