Python3+selenium Frame Design 08-Further realization of POM

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.