From 38c6212a2827c2263be7bd9692861ea2bce0b047 Mon Sep 17 00:00:00 2001 From: cesar991 Date: Mon, 4 Jul 2016 16:45:21 +0200 Subject: [PATCH] Fixed PAN5 --- tests/console/PAN5.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/console/PAN5.py b/tests/console/PAN5.py index 783d6719ef..3d09b4014f 100644 --- a/tests/console/PAN5.py +++ b/tests/console/PAN5.py @@ -5,7 +5,7 @@ from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select -from selenium.common.exceptions import StaleElementReferenceException +from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException import unittest, time, re class PAN5(PandoraWebDriverTestCase): @@ -49,6 +49,31 @@ class PAN5(PandoraWebDriverTestCase): driver.find_element_by_id("submit-srcbutton").click() driver.find_element_by_css_selector("b").click() driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[3]/a/img').click() + max_retries = 3 + i = 1 + while (i <= max_retries): # Temporary workaround to weird StaleElementReferenceException exceptions due Javascript altering the DOM + try: + element = refresh_N_times_until_find_element(driver,5,'//*[@id="table2-0-2"]/a/img',how=By.XPATH) + element.click() + break + except StaleElementReferenceException as e_stale: + i = i+1 + if i > max_retries: + self.verificationErrors.append(str(e_stale)) + break + else: + next + except NoSuchElementException as e_nosuch: + i = i+1 + if i > max_retries: + self.verificationErrors.append(str(e_stale)) + break + else: + next + except AssertionError as e: + self.verificationErrors.append(str(e)) + break + driver.find_element_by_xpath('//*[@id="table2-0-2"]/a/img').click() click_menu_element(driver,"View events")