我正在尝试继承测试中的浏览器类。有人可以指出我在这里做错了吗。我是python的新手
这是我试图继承浏览器类的测试类
import unittest
from Configurations.Browser import Browser
class GoogleTest(Browser):
def test_homepage(self):
driver = self.driver
self.driver.implicitly_wait(10) self.driver.find_element_by_xpath("/html/body/div/div[4]/form/div[2]/div[1]/div[1]/div/div[2]/input").send_keys("Test")
Browser.py:
import unittest
from selenium import webdriver
class Browser(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox(executablepath=r"C:\Setups\Selenium\Drivers\geckodriver.exe")
self.driver.implicitly_wait(10)
self.driver.maximize_window()
self.driver.get("https://www.google.com")
def tearDown(self):
if(self.driver != None):
self.driver.close()
self.driver.quit()
if __name__ == '__main__':
unittest.main()
答案 0 :(得分:2)
您必须将“可执行路径”更改为“可执行路径”。(Browser.py)
像这样
self.driver = webdriver.Firefox(executable_path=r"C:\Setups\Selenium\Drivers\geckodriver.exe")