Before attempting to click on an element, make sure to switch to the new tab first. Wait for the element to be present and in a clickable state using the ExpectedConditions
instance and the elementToBeClickable()
function in Protractor. Once the element is clickable, perform a click()
action. Protractor's click()
function should automatically scroll the page without requiring manual scrolling. Here's how it works -
browser.getAllWindowHandles().then(function(handles){
browser.switchTo().window(handles[1]).then(function(){
var elem = element(by.partialLinkText("RESUME"));
browser.wait(protractor.ExpectedConditions.elementToBeClickable(elem), 10000)
.then(function(){
elem.click();
});
});
});
If the above code still doesn't work, consider adding a scroll line before clicking by resolving the promise that the functions return. Here's how you can do it -
var elem = element(by.partialLinkText("RESUME"));
browser.wait(protractor.ExpectedConditions.elementToBeClickable(elem), 10000)
.then(function(){
elem.getLocation().then(function(loc){
browser.executeScript('window.scrollTo('+loc.x+','+loc.y+');').then(function(){
elem.click();
});
});
});
I hope this explanation helps.