selenium-wire icon indicating copy to clipboard operation
selenium-wire copied to clipboard

Browser scrolls top automatically after page is loaded

Open PythonMaster233 opened this issue 3 years ago • 0 comments

Hello, thank you for your work. This library is really useful. I have a following problem. I use Selenium Wire in automated testing. I use the eager page load strategy and also for some reasons first scroll to every element I am trying to interact with. I also use ActionChains. And my browser created with Selenium Wire scrolls to the top of the page just a few milliseconds before the page finishes its loading. This doesn't happen when I create it using pure selenium. The problem is sometimes I scroll to the element before the page ends loading(eager strategy). So when I try to click it, mouse down is performed but then the page ends loading and the browser scrolls top by itself, so it has not enough time to perform mouse up and the click doesn't happen (though selenium thinks he did everything right). I also noticed I had some failed clicks and they all were related to this automatic scroll, but I can't properly explain why. This also makes my screenshots less representative, because sometimes I see just header of the page instead of my scope elements. Is there a way to disable this scrolling top by itself and have regular behavior when it keeps your current scrolling position after page ended its loading?

My code:

from seleniumwire.webdriver import Chrome
from webdriver_manager.chrome import ChromeDriverManager

driver = Chrome(ChromeDriverManager().install())
driver.get('Any url that has load time enough to perform a little scroll down')

(Then you scroll down while loading and it throws you to the header when the loading ends. If I change "seleniumwire" -> "selenium" it doesn't happen)

Chrome version: 97.0.4692.71 (Official Build) (64-bit) Ubuntu 20.04 This also happens with Firefox and GeckoDriver. Thank you in advance

PythonMaster233 avatar Jan 18 '22 21:01 PythonMaster233