Exemple #1
0
 def get_text_from_element(self, locator, timeout=general.default_timeout):
     try:
         element = self.find_element(locator, timeout)
         element_text = element.text
         return element_text
     except Exception as e:
         utils.log("Fail to find text for " + locator[1])
         raise e
Exemple #2
0
 def find_by_Xpath(self, xpath, timeout=general.default_timeout):
     try:
         element = WebDriverWait(self.webdriver, timeout).until(
             EC.visibility_of_element_located((By.XPATH, xpath)))
         return element
     except Exception:
         traceback.print_exc()
         utils.log(xpath + " not found")
Exemple #3
0
 def click_by_Xpath(self, xpath, timeout=general.default_timeout):
     try:
         element = WebDriverWait(self.webdriver, timeout).until(
             EC.visibility_of_element_located((By.XPATH, xpath)))
         element.click()
     except Exception:
         traceback.print_exc()
         utils.log(xpath + " cannot be clicked")
Exemple #4
0
 def is_navigated_to_selected_coin_pair_trade_page(self, coin_pair):
     utils.log('selected coin pair:' + coin_pair)
     is_navigated = False
     coin_pair_toggle_text = self.get_text_from_element(
         TradeEle.pair_toggle)
     utils.log('coin pair toggle text :' + coin_pair_toggle_text)
     if coin_pair in coin_pair_toggle_text:
         is_navigated = True
     return is_navigated
Exemple #5
0
 def screenshot(self, name):
     screendir = utils.check_screen_shot_report_folder()
     try:
         timestamp = str(time.strftime("%Y%m%d-%H%M%S"))
         screenshot_name = timestamp + "_" + name + ".png"
         utils.log("Taking screenshot:" + screendir + screenshot_name)
         self.webdriver.get_screenshot_as_file(screendir + screenshot_name)
     except Exception as e:
         print(e)
    def click_trade_button_for_coin_pair(self, market, coin_pair):
        utils.log("SELECTED COIN PAIR:" + coin_pair)
        source = coin_pair.split('/')[0]
        target = coin_pair.split('/')[1]
        target_formatted = "/" + coin_pair.split('/')[1]

        if str(market) == "BTC Markets":
            selected_market = "BTC"
        elif str(market) == "USDT Markets":
            selected_market = "USDT"
        elif str(market) == "CRO Markets":
            selected_market = "CRO"

        utils.log("source:" + source)
        utils.log("target:" + target)
        utils.log("selected market:" + selected_market)

        if source == selected_market and target != selected_market:  # For ex: CRO/USDC
            coin_pair_trade_button_xpath = ExchangeEle.coin_pair_trade_button_from_target[
                1].replace('replace_value', target_formatted)
        elif target == selected_market and source != selected_market:  # For ex: ZIL/CRO
            coin_pair_trade_button_xpath = ExchangeEle.coin_pair_trade_button_from_source[
                1].replace('replace_value', source)

        trade_elem = self.find_by_Xpath(coin_pair_trade_button_xpath)
        trade_elem.send_keys(Keys.ENTER)
Exemple #7
0
 def find_elements(self,
                   locator,
                   timeout=general.default_timeout,
                   is_visible=True):
     try:
         if is_visible:
             elements = WebDriverWait(self.webdriver, timeout).until(
                 EC.visibility_of_all_elements_located(locator))
             return elements
         else:
             elements = WebDriverWait(self.webdriver, timeout).until(
                 EC.presence_of_all_elements_located(locator))
             return elements
     except Exception as e:
         traceback.print_exc()
         utils.log(locator[1] + " not found")
         raise e
Exemple #8
0
 def click_element(self, locator, timeout=general.default_timeout):
     try:
         element = WebDriverWait(self.webdriver, timeout).until(
             EC.presence_of_element_located(locator))
         element.click()
     except:
         try:
             element = WebDriverWait(self.webdriver, timeout).until(
                 EC.element_to_be_clickable(locator))
             element.click()
         except:
             try:
                 element = WebDriverWait(self.webdriver, timeout).until(
                     EC.visibility_of_element_located(locator))
                 self.webdriver.execute_script("arguments[0].click();",
                                               element)
             except Exception as e:
                 traceback.print_exc()
                 utils.log(locator[1] + " cannot be clicked")
 def select_market(self, market):
     utils.log("SELECTED MARKET:" + str(market))
     markets = self.find_elements(ExchangeEle.market_tabs)
     for mrkt in markets:
         if mrkt.text == market:
             mrkt.click()
Exemple #10
0
 def __init__(self):
     utils.log("PROJECT PATH: " + project_folder)
     self.chromeDriverPath = project_folder + '/features/UTIL/driver/chromedriver.exe'
     self.testEnvironment = "https://crypto.com/exchange"