How to use testStep method in fMBT

Best Python code snippet using fMBT_python

BrokenImage.py

Source:BrokenImage.py Github

copy

Full Screen

1import requests2from appium.webdriver.common.mobileby import MobileBy as By3from hotdog.TestStep import TestStep4from Helpers.BasePage import BasePage5from time import sleep6from Helpers.BaseWebElement import BaseWebElement7class Footer(BaseWebElement):8 _link = (By.TAG_NAME, 'a')9 @property10 @TestStep('Find Footer Link')11 def link(self):12 return self.find('_link')13class BrokenImage(BasePage):14 sync_element = (By.CLASS_NAME, "example")15 _header = (By.TAG_NAME, 'h3')16 _img1 = (By.CSS_SELECTOR, 'img[src="asdf.jpg"]')17 _img2 = (By.CSS_SELECTOR, 'img[src="hjkl.jpg"]')18 _img3 = (By.CSS_SELECTOR, 'img[src="img/avatar-blank.jpg"]')19 _footer = (By.ID, 'page-footer')20 @TestStep('Find Link With Text - {args[1]}')21 def link(self, title):22 return self.driver.find_element(by = By.XPATH, value = "//a[text()='%s']" % title)23 @TestStep('Click on Link with title {args[1]}')24 def click_on_link(self, title):25 return self.link(title).click()26 @property27 @TestStep('Find Footer')28 def footer(self):29 return self.find('_footer', Footer)30 @property31 @TestStep('Get Header Text', True)32 def header_text(self):33 return self.find('_header').text34 @property35 @TestStep('Find First Image')36 def image1(self):37 return self.find('_img1')38 @property39 @TestStep('Find Second Image')40 def image2(self):41 return self.find('_img2')42 @property43 @TestStep('Find Third Image')44 def image3(self):45 return self.find('_img3')46 @TestStep('Check if image is displayed - {args[1].get_attribute("src")}')47 def image_displayed(self, img):48 r = requests.get(img.get_attribute('src'))...

Full Screen

Full Screen

HomePage.py

Source:HomePage.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3from Public.BasePage import BasePage4from Public.Decorator import *5from uiautomator2 import UiObjectNotFoundError6class HomePage(BasePage):7 @teststep8 def wait_page(self):9 try:10 if self.d(text='HOME').wait(timeout=15):11 pass12 else:13 raise Exception('Not in HonePage')14 except Exception:15 raise Exception('Not in HonePage')16 @teststep17 def home_click(self):18 self.d(text='HOME').click()19 @teststep20 def home_list_click(self):21 self.d(text='list').click()22 @teststep23 def webview_click(self):24 self.d(text='Webview').click()25 @teststep26 def baidu_click(self):27 self.d(text='Baidu').click()28 @teststep29 def personal_click(self):30 self.d(text='PERSONAL').click()31 @teststep32 def personal_logout_click(self):33 self.d(text='Logout').click()34def logout():35 page = HomePage()36 page.webview_click()37 page.baidu_click()38 page.webview_click()39 page.personal_click()...

Full Screen

Full Screen

LoginPage.py

Source:LoginPage.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3from Public.BasePage import BasePage4from Public.Decorator import *5from uiautomator2 import UiObjectNotFoundError6class LoginPage(BasePage):7 @teststep8 def wait_page(self):9 try:10 if self.d(text='Login').wait(timeout=15):11 return True12 else:13 raise Exception('Not in LoginPage')14 except Exception:15 raise Exception('Not in LoginPage')16 @teststep17 def input_username(self, text):18 self.d(resourceId="com.github.android_app_bootstrap:id/mobileNoEditText") \19 .set_text(text)20 @teststep21 def inputpassword(self, text):22 self.d(resourceId="com.github.android_app_bootstrap:id/codeEditText") \23 .set_text(text)24 @teststep25 def login_click(self):26 self.d(text='Login').click()27def login(username, password):28 page = LoginPage()29 page.input_username(username)30 page.inputpassword(password)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful