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
  • 24,667
  • 25
  • 136
  • 263

1 Answers1

2

You need to return the value returned by isLogin()

isLogin = driver.execute_script('return isLogin();')
Guy
  • 40,130
  • 10
  • 33
  • 74