Can Selenium web driver have access to javascript global variables?

0
0

Hi: I’m writing tests for django with javascript and I was wondering if the Selenium webdriver can access a javascript global variable. mypage has a script that has a global variable I’d like to access. Is it possible? Thanks!

from django.test import LiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver
class TestEditorSelenium(LiveServerTestCase):
def setUp(self):
self
.driver = WebDriver()
def test_mytest(self):
self
.driver.get('%s%s' % (self.live_server_url, '/mypage/'))
  • You must to post comments
0
0

Yes, you should be able to that with code similar to the below:

browser.execute_script("return globalVar;")
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website