Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.4k views
by Contributing Tester (92 points)
edited by

selenium.WebDriverException with Selenium 3 & FF

 

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.support.ui import WebDriverWait
from selenium.w

ebdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException

import os
import subprocess
import time

driver = webdriver.Chrome()
driver.get("file:///path/to/index.html")
time.sleep(5)
print driver.execute_script("return roger;")

driver.close()

 

<title>test</title> <script type="text/javascript"> var roger = 10; function init() { console.log("roger : "+roger); } </script>
toto

 

Error--

Traceback (most recent call last):
File "test.py", line 22, in 
print driver.execute_script("return roger;")
File "/netShare/home/buildsystem/Desktop/virgile/TEST/SELENIUM/selenium/webdriver/remote/webdriver.py", line 467, in execute_script
'args': converted_args})['value']
File "/netShare/home/buildsystem/Desktop/virgile/TEST/SELENIUM/selenium/webdriver/remote/webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "/netShare/home/buildsystem/Desktop/virgile/TEST/SELENIUM/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: ReferenceError: roger is not defined

1 Answer

1 like 0 dislike
by The go-to Tester (181 points)

This is a JavaScript error.

As per your code, you are trying to execute the script and return value of roger.

Eiter the variable roger does not exist or remove semicolon from your script.

try below line instead.

print driver.execute_script("return roger")

 


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...