Smart XPATH determination
This commit is contained in:
parent
5410fa6681
commit
140e33e089
|
@ -48,6 +48,8 @@ class BaseCase(unittest.TestCase):
|
|||
|
||||
def click(self, selector, by=By.CSS_SELECTOR,
|
||||
timeout=settings.SMALL_TIMEOUT):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
element = page_actions.wait_for_element_visible(
|
||||
self.driver, selector, by, timeout=timeout)
|
||||
self._demo_mode_scroll_if_active(selector, by)
|
||||
|
@ -112,9 +114,13 @@ class BaseCase(unittest.TestCase):
|
|||
timeout=timeout, retry=retry)
|
||||
|
||||
def is_element_present(self, selector, by=By.CSS_SELECTOR):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.is_element_present(self.driver, selector, by)
|
||||
|
||||
def is_element_visible(self, selector, by=By.CSS_SELECTOR):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.is_element_visible(self.driver, selector, by)
|
||||
|
||||
def is_link_text_visible(self, link_text):
|
||||
|
@ -122,9 +128,13 @@ class BaseCase(unittest.TestCase):
|
|||
by=By.LINK_TEXT)
|
||||
|
||||
def is_text_visible(self, text, selector, by=By.CSS_SELECTOR):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.is_text_visible(self.driver, text, selector, by)
|
||||
|
||||
def find_visible_elements(self, selector, by=By.CSS_SELECTOR):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.find_visible_elements(self.driver, selector, by)
|
||||
|
||||
def execute_script(self, script):
|
||||
|
@ -216,6 +226,8 @@ class BaseCase(unittest.TestCase):
|
|||
def hover_and_click(self, hover_selector, click_selector,
|
||||
click_by=By.CSS_SELECTOR,
|
||||
timeout=settings.SMALL_TIMEOUT):
|
||||
if click_selector.startswith('/'):
|
||||
click_by = By.XPATH
|
||||
self.wait_for_element_visible(hover_selector, timeout=timeout)
|
||||
self.scroll_to(hover_selector)
|
||||
# Settle down from the scrolling before hovering
|
||||
|
@ -226,16 +238,22 @@ class BaseCase(unittest.TestCase):
|
|||
|
||||
def wait_for_element_present(self, selector, by=By.CSS_SELECTOR,
|
||||
timeout=settings.LARGE_TIMEOUT):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.wait_for_element_present(
|
||||
self.driver, selector, by, timeout)
|
||||
|
||||
def wait_for_element_visible(self, selector, by=By.CSS_SELECTOR,
|
||||
timeout=settings.LARGE_TIMEOUT):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.wait_for_element_visible(
|
||||
self.driver, selector, by, timeout)
|
||||
|
||||
def wait_for_text_visible(self, text, selector, by=By.CSS_SELECTOR,
|
||||
timeout=settings.LARGE_TIMEOUT):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.wait_for_text_visible(
|
||||
self.driver, text, selector, by, timeout)
|
||||
|
||||
|
@ -246,11 +264,15 @@ class BaseCase(unittest.TestCase):
|
|||
|
||||
def wait_for_element_absent(self, selector, by=By.CSS_SELECTOR,
|
||||
timeout=settings.LARGE_TIMEOUT):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.wait_for_element_absent(
|
||||
self.driver, selector, by, timeout)
|
||||
|
||||
def wait_for_element_not_visible(self, selector, by=By.CSS_SELECTOR,
|
||||
timeout=settings.LARGE_TIMEOUT):
|
||||
if selector.startswith('/'):
|
||||
by = By.XPATH
|
||||
return page_actions.wait_for_element_not_visible(
|
||||
self.driver, selector, by, timeout)
|
||||
|
||||
|
|
Loading…
Reference in New Issue