Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import time
from time import sleep
from import By
from import Select
from import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from appium.webdriver.common.touch_action import TouchAction
from 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), y=y_point).release().perform()
"""Return True if element is Present on UI"""
def is_element_displayed(self, by, locator):
is_present = False
self.driver.find_element(by, locator).is_displayed()
is_present = True
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):
Functions(self.driver).wait_for_element(By.ID, 'com.healthywage:id/tvUserName', 'My Team Chatting Screen')
Copy link

prat3ik commented Apr 14, 2018

File "/Users/harry/Documents/test_pratik/HealthyWage/Android/src/pageobject/", 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