Skip to content

Instantly share code, notes, and snippets.

@prat3ik
Last active April 14, 2018 14:12
Show Gist options
  • Save prat3ik/eab1f0427a04304256b238aba22158e5 to your computer and use it in GitHub Desktop.
Save prat3ik/eab1f0427a04304256b238aba22158e5 to your computer and use it in GitHub Desktop.
Python_Appium_code
import time
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support import expected_conditions as EC
class BasePage(object):
"""Base class to initialize the base page that will be called from all pages"""
def __init__(self, driver):
self.driver = driver
"""This class will contains the basic functions used throughout the testing"""
class Functions(BasePage):
"""Wait till element is present"""
def wait_for_element(self, by, locator, screenName):
print ''
starttime = time.time()
wait = WebDriverWait(self.driver, 60, poll_frequency=1)
wait.until(EC.visibility_of_element_located((by, locator)))
endtime = time.time()
print "Loading time for " + screenName + " is: " + str((endtime - starttime)) + "(seconds)"
"""It will tap on fix point on screen"""
def tap_on_point(self, x_point, y_point):
action = TouchAction(self.driver)
action.press(x=x_point, y=y_point).release().perform()
"""Return True if element is Present on UI"""
def is_element_displayed(self, by, locator):
is_present = False
try:
self.driver.find_element(by, locator).is_displayed()
is_present = True
except:
is_present = False
return is_present
return is_present and self.driver.find_element(by, locator).is_displayed()
"""This class will contains the basic functions used throughout the chatting"""
class ChatScreen(BasePage):
"""This method would move to chat screen """
------> Functions(self.driver).wait_for_element(By.ID, 'com.healthywage:id/tvUserName', 'Chatting Screen')
"""Wait till element is present"""
def move_to_my_team(self):
move_to_chat_screen(self)
self.driver.find_element_by_xpath(*ChatScreenLocators.MY_TEAM_TAB).click()
Functions(self.driver).wait_for_element(By.ID, 'com.healthywage:id/tvUserName', 'My Team Chatting Screen')
@prat3ik
Copy link
Author

prat3ik commented Apr 14, 2018

File "/Users/harry/Documents/test_pratik/HealthyWage/Android/src/pageobject/page.py", line 52, in ChatScreen
Functions(self.driver).wait_for_element(By.ID, 'com.healthywage:id/tvUserName', 'Chatting Screen')
NameError: name 'self' is not defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment