1
我有一個功能測試'y1.py',我從selenium IDE中導出。它看起來像:如何從django視圖運行unitest和selenium?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class Y1(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "https://www.yahoo.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_y1(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_link_text("Weather").click()
driver.save_screenshot('out11.png')
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
我想直接從一個python/django函數內調用此。同時調查這個我碰到:AttributeError 'module' object has no attribute 'runserver' in django,其中Udi狀態:
您是否試圖從視圖運行unitest和硒?您應該考慮爲此啓動第二個流程。
我該怎麼做?
謝謝,這有助於 – user61629