Previously there was only one page, one use case. This two page. Two test cases. In fact, the biggest difficulty of interface automation testing is the driver of the transmission, need to remain unique. The other is the difficulty of assertion.
Add the baidu_new_page.py file under the PageObject folder, the code is as follows.
fromFramework. Base_pageImportBasePageclassNewPage (basepage): WW= ['ID','ww'] WR= ['ID','S_BTN_WR'] defType_ww (self): Self.type (Self.ww,'Selenium') defCLICK_WR (self): Self.click (SELF.WR)
Add the test_baidu_new.py file under the Testsuites folder. The code is as follows
ImportUnitTest fromFramework. Base_pageImportBasePage fromPageobject.baidu_new_pageImportNewPage fromPageObject. BaidupageImportBaidupageclasstest_baidu_new (unittest. TestCase):" "Baidu News" " defsetUp (self): Bro=basepage (self) self.driver=Bro.open_browser (self)deftest_new (self):" "Search Selenium" "Baidu=baidupage (Self.driver) baidu.click_new () New=NewPage (Self.driver) new.type_ww () NEW.CLICK_WR () new.quit ()
When creating a page instance, be sure to pass the self.driver in.
The entrance.py file code is as follows
ImportTestsuites.test_baiduImporttestsuites.test_baidu_newImportUnitTestif __name__=="__main__": Suite=UnitTest. TestSuite () suite.addtest (Testsuites.test_baidu.test_baidu ('Test_baisu')) Suite.addtest (Testsuites.test_baidu_new.test_baidu_new ('test_new')) Runner=UnitTest. Texttestrunner () Runner.run (suite)
?
My side of the successful implementation, after Baidu search is done, close the browser, and then start to perform the news search use cases.
These test cases are not the most complete, because it is generally necessary to assert the execution results, and log output assertion results and line feed, so that the log output to facilitate reading, and now the logs are linked together.
Python3+selenium Frame Design 08-Further realization of POM