CENTREON – Contrôler et mesurer le ressenti utilisateur

En complément de contrôler les services disponible pour les utilisateurs, nous pouvons contrôler et mesurer le ressenti utilisateur garce à centreon et selenium.

Après avoir lancé Selenium-Docker, vous installé sur une machine selenium et utilisé des scripts
# -*- coding: utf-8 -*-
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 NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class Testpy(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.driver = webdriver.Remote("http://10.200.10.146:5555/wd/hub", webdriver.DesiredCapabilities.FIREFOX.copy())
self.driver.implicitly_wait(30)
self.base_url = "http://www.google.fr/"
self.accept_next_alert = True

def test_py13(self):
driver = self.driver
# open | /ui/ |
driver.get(self.base_url + "/ui/")
# type | id=loginUserId | LOGIN
driver.find_element_by_id("loginUserId").clear()
driver.find_element_by_id("loginUserId").send_keys("LOGIN")
# type | id=loginPassword | PASSWORD
driver.find_element_by_id("loginPassword").clear()
driver.find_element_by_id("loginPassword").send_keys("PASSWORD")
# click | id=N10090 |
driver.find_element_by_id("N10090").click()
# verifyText | //span[@id='cat_sectionN100CC']/table[2]/tbody/tr[2]/td[3] | Running
try: self.assertEqual("Running", driver.find_element_by_xpath("//span[@id='cat_sectionN100CC']/table[2]/tbody/tr[2]/td[3]").text)
except AssertionError as e: self.verificationErrors.append(str(e))
# verifyText | //span[@id='cat_sectionN10106']/table/tbody/tr[2]/td[4] | Running
try: self.assertEqual("Running", driver.find_element_by_xpath("//span[@id='cat_sectionN10106']/table/tbody/tr[2]/td[4]").text)
except AssertionError as e: self.verificationErrors.append(str(e))
# click | link=Logout |
driver.find_element_by_link_text("Logout").click()
# close | |
driver.close()

def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True

def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True

#def tearDown(self):
# self.driver.quit()
self.selenium.stop()
self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
unittest.main()

Taggé , , , , , , , .Mettre en favori le Permaliens.

Les commentaires sont fermés.