Selenium does not run a javascript

249 Views Asked by At

I'm trying to execute a simple java script command at selenium using python for scroll a part of a web page.

Here's the code:

command_js = 'document.querySelector(' + "'" + 'css_div_example[css_example="this is just a example for css selector"]' + "').scroll(0, 10000)"
#string joined "document.querySelector('css_div_example[css_example="this is just a example for css selector"]').scroll(0, 10000)"
driver.execute_script(command_js)

Picture:

Picture of scroll bar

OBS.:

  • I tried to execute directly from Firefox console and it worked very well.
  • Selenium does not return any error, just not execute it.
  • I tried to WebDriverWait with EC and time.sleep().
  • I am using python 3+ and PyCharm IDE, Firefox webdrivers...

Anyone can help me?

0

There are 0 best solutions below