Answer the question
In order to leave comments, you need to log in
How to correctly change the autotest code to launch the browser?
Absolute newbie in python + selenium autotests. Got a question.
Pieces of code from an elementary test.
The browser opens, there are no errors in the pycharm console:
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://ya.ru')
from selenium import webdriver
def auth(self):
self.driver = webdriver.Chrome()
self.driver.maximize_window()
self.driver.get("http://ya.ru")
Answer the question
In order to leave comments, you need to log in
You're declaring a function, but you're doing it without respect and don't call it. Therefore, nothing happens - try writing its call.
In addition, you need to add a description of the class, you are passing the self parameter, which points to an instance of the class, but there is no class itself.
from selenium import webdriver
import unittest
class auth_test(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
def test_auth(self):
self.auth()
def tearDown(self):
self.driver.close()
def auth(self):
self.driver.get("http://ya.ru")
if __name__ == "__main__":
unittest.main()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question