Selenium webdriver can't click on a link outside the page

前端 未结 10 1282
走了就别回头了
走了就别回头了 2020-11-28 10:50

I am having an issue with Selenium WebDriver. I try to click on a link that is outside the window page (you\'d need to scroll up to see it). My current code is fairly standa

10条回答
  •  无人及你
    2020-11-28 11:16

    I posted this same answer in another question so this is just a copy and paste.

    I once had a combo box that wasn't in view that I needed to expand. What I did was use the Actions builder because the moveToElement() function will automatically scroll the object into view. Then it can be clicked on.

    WebElement element = panel.findElement(By.className("tabComboBoxButton"));
    
    Actions builder = new Actions(this.driver);
    
    builder.moveToElement(element);
    builder.click();
    builder.build().perform();
    

    (panel is simply a wrapped element in my POM)

提交回复
热议问题