在运行脚本时,请考虑以下发布步骤。
我已经尝试从下面的URL中获取代码,但是没有答案。 Python and Selenium, calling one test from another
from selenium import webdriver
import unittest
import time
class login(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox(executable_path="mylocalpath\\geckodriver.exe")
driver = self.driver
driver.get("myurl")
time.sleep(5)
def test_LoginLink(self):
self.link = self.driver.find_element_by_xpath("/html/body/div[6]/div/div[1]/div[2]/div/div[3]/div[2]/a[2]")
self.link.click()
time.sleep(5)
def test_forgot(self):
driver = self.driver
self.link1 = driver.find_element_by_xpath("/html/body/div[5]/div/div[3]/div/div/div[2]/div/form/div[2]/a")
self.link1.click()
time.sleep(3)
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()