Python UnitTest Appium

Source: Internet
Author: User
Tags appium

Import unittestfrom appium import webdriverfrom appium.common.exceptions import Nosuchcontextexceptionimport desired_ Capabilitiesclass contextswitchingtests (unittest. TestCase): def setUp (self): Desired_caps = desired_capabilities.get_desired_capabilities (' Selendroid-test-app.ap K ') Self.driver = Webdriver.        Remote (' Http://localhost:4723/wd/hub ', desired_caps) def test_contexts_list (self): Self._enter_webview ()        contexts = Self.driver.contexts self.assertequal (2, Len (contexts)) def test_move_to_correct_context (self): Self._enter_webview () self.assertequal (' WEBVIEW_io.selendroid.testapp ', self.driver.current_context) def Test_ Actually_in_webview (self): Self._enter_webview () self.driver.find_element_by_css_selector (' Input[type=submit ]. Click () el = Self.driver.find_element_by_xpath ("//h1[contains (., ' This is my")] Self.assertisnot (N One, EL) def test_move_back_to_native_context (self): self. _enter_webview () Self.driver.switch_to.context (None) self.assertequal (' Native_app ', Self.driver.current_con Text) def test_set_invalid_context (self): self.assertraises (Nosuchcontextexception, Self.driver.switch_to.contex T, ' invalid name ') def tearDown (self): Self.driver.quit () def _enter_webview (self): BTN = Self.driver.  Find_element_by_name (' BUTTONSTARTWEBVIEWCD ') Btn.click () self.driver.switch_to.context (' WEBVIEW ') if __name__ = = "__main__": Suite = unittest. Testloader (). Loadtestsfromtestcase (contextswitchingtests) unittest. Texttestrunner (verbosity=2). Run (Suite)

  

Python UnitTest Appium

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.