Попытка запустить тест на python и selenium, и я получаю ошибку атрибута: у объекта нет драйвера атрибута '.Куда я иду не так?Ошибка ниже.Урезал код.проблема в настройке и первых 4 или 5 строках функции test_selenium
======================================================================
ERROR: test_selenium (__main__.Servicenow_IncCreate)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:/firefox_inccreate_cloudv2.py", line 27, in test_selenium
driver = self.driver
AttributeError: 'Servicenow_IncCreate' object has no attribute 'driver'
----------------------------------------------------------------------
Ran 1 test in 0.011s
FAILED (errors=1)
The Python code is - >
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from datetime import date
from selenium.webdriver.common.action_chains import ActionChains
import unittest
class Servicenow_IncCreate(unittest.TestCase):
def setup(self):
self.driver = webdriver.Firefox()
def test_selenium(self):
#
today = str(date.today())
base_url = "xxx"
driver = self.driver
driver.get(base_url)
driver.switch_to_frame("gsft_main")
username = driver.find_element_by_id("xxxx")
username.send_keys("admin")
password = driver.find_element_by_id("user_password")
password.send_keys("xxxx")
password.send_keys(Keys.RETURN)
def teardown(self):
self.driver.close()
if __name__ == '__main__':
unittest.main()