Added several functions and refactorized all console CI tests
This commit is contained in:
parent
221d0acaa0
commit
9de246554d
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login
|
||||
from include.common_functions_60 import login, click_menu_element
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
@ -17,8 +17,7 @@ class PAN1(PandoraWebDriverTestCase):
|
|||
def test_pan1(self):
|
||||
driver = self.driver
|
||||
login(driver,"admin","pandora",self.base_url)
|
||||
element = driver.find_element_by_css_selector("#subSetup > li.sub_subMenu > a > div.submenu_text.submenu2_text_middle")
|
||||
driver.execute_script("arguments[0].click();", element)
|
||||
click_menu_element(driver,"General Setup")
|
||||
self.assertEqual("IP list with API access", driver.find_element_by_id("table2-15-0").text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login
|
||||
from include.common_functions_60 import login, click_menu_element
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
@ -17,16 +17,14 @@ class PAN2(PandoraWebDriverTestCase):
|
|||
def test_pan2(self):
|
||||
driver = self.driver
|
||||
login(driver,"admin","pandora",self.base_url)
|
||||
element = driver.find_element_by_xpath("//ul[@id='subViews']/li[4]/a/div")
|
||||
driver.execute_script("arguments[0].click();", element)
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_id("text-agente").click()
|
||||
driver.find_element_by_id("text-agente").clear()
|
||||
driver.find_element_by_id("text-agente").send_keys("prueba masivas 1")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
element = driver.find_element_by_xpath("//ul[@id='subViews']/li[4]/a/div")
|
||||
driver.execute_script("arguments[0].click();", element)
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_id("text-agente").click()
|
||||
driver.find_element_by_id("text-agente").clear()
|
||||
|
@ -34,8 +32,7 @@ class PAN2(PandoraWebDriverTestCase):
|
|||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
element = driver.find_element_by_css_selector('#subBulk_operations > li.sub_subMenu > a > div.submenu_text.submenu2_text_middle')
|
||||
driver.execute_script("arguments[0].click();", element)
|
||||
click_menu_element(driver,"Agents operations")
|
||||
driver.find_element_by_id("option").click()
|
||||
Select(driver.find_element_by_id("option")).select_by_visible_text("Bulk agent delete")
|
||||
Select(driver.find_element_by_id("id_agents")).select_by_visible_text("prueba masivas 1")
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from selenium import selenium
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
def login(driver,user="admin",passwd="pandora",pandora_url="http://127.0.0.1/"):
|
||||
driver.get(pandora_url+"/pandora_console/index.php")
|
||||
|
@ -8,3 +11,24 @@ def login(driver,user="admin",passwd="pandora",pandora_url="http://127.0.0.1/"):
|
|||
driver.find_element_by_id("pass").clear()
|
||||
driver.find_element_by_id("pass").send_keys(passwd)
|
||||
driver.find_element_by_id("submit-login_button").click()
|
||||
|
||||
def get_menu_element(driver,menu_item_text):
|
||||
return driver.find_element_by_xpath('//div[@class="menu"]//a[contains(.,"'+menu_item_text+'")]')
|
||||
|
||||
def click_menu_element(driver,menu_item_text):
|
||||
return driver.execute_script("arguments[0].click();", get_menu_element(driver,menu_item_text))
|
||||
|
||||
def refresh_N_times_until_find_element(driver,n,element_text,how=By.ID,refresh_time=10):
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
|
||||
i = 1
|
||||
while (1<=n):
|
||||
try:
|
||||
element = WebDriverWait(driver, refresh_time).until(EC.presence_of_element_located((how, element_text)))
|
||||
return element
|
||||
except:
|
||||
driver.get(driver.current_url)
|
||||
i = i+1
|
||||
|
||||
raise TimeoutException("Element %s not found" % (element_text))
|
||||
|
||||
|
|
Loading…
Reference in New Issue