def test_registration_in_python_org(self): driver = self.driver with open('../Data/data.json') as json_file: self.logger = HTMlLogger( 'C:/Users/user/PycharmProjects/Selenium03') data = json.load(json_file) driver.get('http://demo.guru99.com/test/newtours/') # debug_request(driver) driver.save_screenshot('./ScreenShots/sc1.png') driver.set_page_load_timeout(20) m = Home(driver) m.getRegister(driver).click() self.logger.assert_step_log( "Navigated successfully to the register page") r = Register(driver) r.setFirstName(data['firstname'], driver) r.setLastName(data['lastname'], driver) r.setPhone(data['mobileno'], driver) r.setCountry(data['country'], driver) r.setEmail(data['emailid'], driver) r.setUserName(data['lastname'], driver) r.setPassword(data['password'], driver) r.setConfirmPassword(data['password'], driver) r.submitRegistration(driver) screenshot.resize_to_page_size(driver) screenshot.get_screenshot(driver, "screenshot.png")
def setUp(self): with open('../Data/data.json', encoding='utf-8') as data_file: self.logger = HTMlLogger( 'C:/Users/user/PycharmProjects/Appium_ATF') data = json.loads(data_file.read()) desired_caps = {} desired_caps['platformName'] = data['platformName'] desired_caps['deviceName'] = data['deviceName'] desired_caps['appPackage'] = data['appPackage'] desired_caps['appActivity'] = data['appActivity'] self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
def setup(request): print("initiating driver") logger = HTMlLogger() binary = FirefoxBinary('Path to your firefox_binary') driver = webdriver.Firefox(firefox_binary=binary, executable_path=r"path to geckodriver") request.instance.driver = driver request.instance.logger = logger driver.get("http://seleniumeasy.com/test") driver.maximize_window() yield driver driver.close()
class InputFormsCheck2(unittest.TestCase): # Opening browser. def setUp(self): self.logger = HTMlLogger( './') # directory path in which report to be created' binary = FirefoxBinary('Binary Path for your browser') self.driver = webdriver.Firefox(firefox_binary=binary, executable_path="driver path") # Testing Single Input Field. def test_singleInputField(self): self.logger.assert_testcase_log("Test Single Input Field") try: pageUrl = "http://www.seleniumeasy.com/test/basic-first-form-demo.html" driver = self.driver driver.maximize_window() driver.get(pageUrl) # Finding "Single input form" input text field by id. And sending keys(entering data) in it. eleUserMessage = driver.find_element_by_id("user-message") eleUserMessage.clear() eleUserMessage.send_keys("Test Python") self.logger.assert_step_log( "Entered text [Test Python] in [user-message] EditBox." ) # Writting step log # Finding "Show Your Message" button element by css selector using both id and class name. And clicking it. eleShowMsgBtn = driver.find_element_by_css_selector( '#get-input > .btn') eleShowMsgBtn.click() self.logger.assert_step_log("Clicked on [Show Message] Button.") # Checking whether the input text and output text are same using assertion. eleYourMsg = driver.find_element_by_id("display") assert "Test Python" in eleYourMsg.text except Exception as e: self.logger.assert_step_fail_log(driver, str(e)) # Closing the browser. def tearDown(self): self.driver.close()
class ContactAppTestAppium(unittest.TestCase): def setUp(self): with open('../Data/data.json', encoding='utf-8') as data_file: self.logger = HTMlLogger( 'C:/Users/user/PycharmProjects/Appium_ATF') data = json.loads(data_file.read()) desired_caps = {} desired_caps['platformName'] = data['platformName'] desired_caps['deviceName'] = data['deviceName'] desired_caps['appPackage'] = data['appPackage'] desired_caps['appActivity'] = data['appActivity'] self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) def tearDown(self): self.driver.quit() def test_single_bankapp(self): with open('../Data/data.json', encoding='utf-8') as data_file: data = json.loads(data_file.read()) # driver = self.driver login = Login(self.driver) login.setUserName(data['User']) login.setPassword(data['User']) login.clickLogin() self.logger.assert_step_log("Logged into the eribank app") time.sleep(3) mainScreen = MainScreen(self.driver) mainScreen.clickMakePayment() self.logger.assert_step_log("Navigated into the make payment screen") makePaymentScreen = MakePayment(self.driver) makePaymentScreen.makePayment(data['tele'], data['name'], data['country']) self.logger.assert_step_log("Did the payment") sleep(5)
def setUp(self): self.logger = HTMlLogger( './') # directory path in which report to be created' binary = FirefoxBinary('Binary Path for your browser') self.driver = webdriver.Firefox(firefox_binary=binary, executable_path="driver path")