'How to hide 'Back to Top' button in script that is only becoming visible after page scroll to the bottom
I am looking help to hide 'Back to Top' button in script that is only becoming visible after page scroll to the bottom so that I can take screenshots.
I am using below code but still see 'Back to Top' button on my page.
if (driver.getPageSource().contains("scroll-to-top"))
{
WebElement element = driver.findElement(By.cssSelector("button[class*='cv-s2t']"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView().style.visibility='hidden'", element);
}
Solution 1:[1]
You can have it keep removing those as they show up:
driver.execute_script("""
setInterval(() => document.querySelector('.cv-s2t')?.remove(), 100)
""")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pguardiario |
