1

I use below code to execute javascript, and it works well.

from selenium import webdriver

driver=webdriver.Firefox()
driver.get("https:example.com")
driver.execute_script('isLogin()')

But when I try to access the result return by isLogin() with

isLogin = driver.execute_script('isLogin()')
print(isLogin)    # always None
LF00
  • 27,015
  • 29
  • 156
  • 295

1 Answers1

2

You need to return the value returned by isLogin()

isLogin = driver.execute_script('return isLogin();')
Guy
  • 46,488
  • 10
  • 44
  • 88