3

I want to create some Django test using Selenium package.

Here below is the simple test :

import unittest
from selenium import webdriver

class TestSignup(unittest.TestCase):

def setUp(self):
    self.driver = webdriver.Firefox()

def test_signup_fire(self):
    self.driver.get("http://localhost:8000/add/")
    self.driver.find_element_by_id('id_title').send_keys("test title")
    self.driver.find_element_by_id('id_body').send_keys("test body")
    self.driver.find_element_by_id('submit').click()
    self.assertIn("http://localhost:8000/", self.driver.current_url)

def tearDown(self):
    self.driver.quit

if __name__ == '__main__':
    unittest.main()

but I take this error :

TypeError: environment can only contain strings

in this line :

self.driver = webdriver.Firefox()

and I don't know why, any idea how to fix this error?

1 Answer 1

1

As you are seeing the error as :

TypeError: environment can only contain strings

In the line :

self.driver = webdriver.Firefox()

This essentially means there is some configuration error while updating the path within Environment Variables. To suppress that you can supply the argument with geckodriver binary location as follows :

self.driver = webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe')
Sign up to request clarification or add additional context in comments.

1 Comment

is the some error o don't need update TypeError: environment can only contain strings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.