Python Selenium driver.execute_script WebDriverExc

2019-01-26 21:40发布

This is actually for the thread on unknown error: call function result missing 'value' for Selenium Send Keys even after chromedriver upgrade but I guess my reputation isn't high enough to participate(lame).

I got the error:

WebDriverException: Message: unknown error: call function result missing 'value'
  (Session info: chrome=65.0.3325.162)
  (Driver info: chromedriver=2.33.506106 
  platform=Mac OS X 10.13.3 x86_64)

when running this line:

driver.execute_script('window.scrollTo(0, %s)' % scroll_to)

I updated and everything else but that error still popped up, however the code actually executed before raising the error, so simply passing the exception allowed me to accomplish my goal, kinda sloppy so it'd be cool if I could make the error go away for real, but this is working for now:

driver.get('https://www.azcentral.com/search/trump/')
page_height = int(driver.get_window_size()['height'])
scroll_to = 0
start_time = time.time()
wait = 90

while True:

    scroll_to += page_height

    try:

        driver.execute_script('window.scrollTo(0, %s)' % scroll_to)

    except:

        time.sleep(1)
        pass

    end_time = time.time()
    uptime = timedelta(seconds=int(end_time - start_time))

    if uptime > timedelta(seconds=wait):

        break

2条回答
我命由我不由天
2楼-- · 2019-01-26 22:37

I think you can use such code for this:

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

Hope it helps you!

查看更多
做自己的国王
3楼-- · 2019-01-26 22:42

The error says it all :

WebDriverException: Message: unknown error: call function result missing 'value'
  (Session info: chrome=65.0.3325.162)
  (Driver info: chromedriver=2.33.506106 

Your main issue is the version compatibility between the binaries you are using as follows :

  • You are using chromedriver=2.33
  • Release Notes of chromedriver=2.33 clearly mentions the following :

Supports Chrome v60-62

  • You are using chrome=65.0
  • Release Notes of ChromeDriver v2.37 clearly mentions the following :

Supports Chrome v64-66

  • Your Selenium Client version is unknown to us.

So there is a clear mismatch between the ChromeDriver version (v2.33) and the Chrome Browser version (v65.0)

Solution

  • Upgrade Selenium to current levels Version 3.11.0.
  • Upgrade ChromeDriver to current ChromeDriver v2.37 level.
  • Keep Chrome version in between Chrome v64.x-66.x levels. (as per ChromeDriver v2.37 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Execute your @Test.
查看更多
登录 后发表回答