예제 #1
0
def sizeTester(browser_name):
    if browser_name == "CHROME":
        driver = webdriver.Chrome(ChromeDriverManager().install())
    elif browser_name == "FIREFOX":
        driver = webdriver.Firefox(executable_path=GeckoDriverManager())
    elif browser_name == "EDGE":
        driver = webdriver.Edge(EdgeChromiumDriverManager().install())
    else:
        return False

    driver.get(INPUT_URL)
    screen_height_sizes = driver.get_window_size()["height"]

    for size in SCREEN_WIDTH_SIZES:
        driver.set_window_size(size, screen_height_sizes)
        driver.execute_script("window.scrollTo(0,0)")
        time.sleep(1)
        page_scroll_size = driver.execute_script("return document.body.scrollHeight")
        scroll_count = ceil(page_scroll_size / screen_height_sizes)
        for scroll in range(scroll_count + 1):
            driver.execute_script(
                f"window.scrollTo(0, {(scroll) * screen_height_sizes})"
            )
            driver.save_screenshot(f"screenshots/{browser_name}_{size}x{scroll}.png")
            time.sleep(1)
    driver.quit()
 def test_opencv(self):
     driver = self.driver
     driver.get("http://www.google.com")
     #driver.set_window_position(0, 0)
     #driver.set_window_size(1366, 768)
     driver.save_screenshot("img2.png")
     time.sleep(3)
 def test_Elementos_En_Tablas(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.w3schools.com/html/html_tables.asp")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("HTML Tables", driver.title)
     time.sleep(3)
     valor = driver.find_element_by_xpath(
         "//*[@id='customers']/tbody/tr[2]/td[2]").text
     print("El resultado por elemento es: ", valor)
     time.sleep(3)
     rows = len(
         driver.find_elements_by_xpath("//*[@id='customers']/tbody/tr"))
     col = len(
         driver.find_elements_by_xpath(
             "//*[@id='customers']/tbody/tr[1]/th"))
     print("El resultado por elemento es: ", rows)
     print("El resultado por elemento es: ", col)
     print("El resultado es: ")
     for n in range(2, rows + 1):
         for b in range(1, col + 1):
             dato = driver.find_element_by_xpath(
                 "//*[@id='customers']/tbody/tr[" + str(n) + "]/td[" +
                 str(b) + "]").text
             print(" - ", dato, end="      ")
             print()
 def test_Llenar_Formulario(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("C:\\Users\\ING\\Desktop\\Automation\\Automation\\Formularios\\Formulario.html")
     time.sleep(5)
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("LogIn Automatizado", driver.title)
     time.sleep(5)
     with open("C:\\Users\\ING\\Desktop\\Automation\\Automation\\Formularios\\Datos.txt") as file:
         for i, line in enumerate(file):
             usuario = (line)
             sep = ","
             dividir = usuario.split(sep)
             try:
                 gotdata = dividir[1]
                 user = dividir[0]
                 pas = dividir[1]
             except IndexError:
                 gotdata = 'null'
             print("Usuario:\t\t", user)
             print("Contraseña:\t", pas)
             driver.find_element_by_id("login").send_keys(user)
             time.sleep(2)
             driver.find_element_by_id("pass").send_keys(pas)
             time.sleep(2)
             driver.find_element_by_id("acce").click()
             time.sleep(2)
     file.close()
예제 #5
0
 def test_Proxy(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.google.com")
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("Google", driver.title)
     time.sleep(5)
 def test_assertEqual(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.google.com")
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertEqual("GoogleDiferencia", driver.title,
                      "El titulo de la pagina no es igual")
     time.sleep(3)
 def test_Funcion_Implicit_Wait(self):
     driver = self.driver
     driver.implicitly_wait(15)  #pausa segundo
     driver.get("http://www.facebook.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Facebook - Inicia sesión o regístrate", driver.title)
     myDinamicElement = driver.find_element_by_name("email")
     print("Funciona", myDinamicElement)
     time.sleep(3)
예제 #8
0
 def test_ScreenShot(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.w3schools.com/html/default.asp")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("HTML Tutorial", driver.title)
     driver.get_screenshot_as_file("C:\\Users\\ING\\Desktop\\Selenium\\ScreenShotNativo.png")
     print("El resultado:\n")
     time.sleep(3)
 def test_Cokies(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.w3schools.com/html/default.asp")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("HTML Tutorial", driver.title)
     all_cokies = driver.get_cookies()
     print("El resultado:\n", all_cokies)
     time.sleep(3)
 def test_Scroll(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("http://www.amazon.com.co")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Amazon", driver.title)
     time.sleep(3)
     driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
     time.sleep(3)
예제 #11
0
 def test_Subir_Archivo(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://mdbootstrap.com/plugins/jquery/file-upload/")
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("Bootstrap File - examples & tutorial", driver.title)
     self.driver.find_element_by_xpath("//*[@id='customFile']").send_keys(
         "C:\\Users\\ING\Desktop\\Selenium\\ScreenShotNativo.png")
     #print("Satisfactorio")
     time.sleep(5)
 def test_CSS_Selector(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.w3schools.com/html/default.asp")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("HTML Tutorial", driver.title)
     time.sleep(5)
     encontrar1 = driver.find_element_by_css_selector('a.w3-blue')
     encontrar1.click()
     time.sleep(3)
 def test_Cokies(self):
     driver = self.driver
     driver.maximize_window()
     driver.implicitly_wait(5) # segundos
     driver.get(self.page)
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Google", driver.title)
     navegador = driver.find_element_by_class_name("q")
     print("El resultado:\n", navegador)
     time.sleep(3)
예제 #14
0
 def test_hover_action(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.google.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Google", driver.title)
     time.sleep(3)
     elem = driver.find_element_by_link_text("Privacidad")
     hover = ActionChains(driver).move_to_element(elem)
     hover.perform()
     time.sleep(5)
 def test_buscar(self):
     driver = self.driver
     driver.get("http://www.facebook.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Facebook - Inicia sesión o regístrate", driver.title)
     elemento = driver.find_element_by_id("email")
     elemento.send_keys("jimmyguerre")
     clave = driver.find_element_by_id("pass")
     clave.send_keys("Intentemos de nuevo")
     clave.send_keys(Keys.ENTER)
     time.sleep(5)
     assert "No se encontro el elemento: " not in driver.page_source
 def test_Buscar_Por_Xpath(self):
     driver = self.driver
     driver.get("http://www.google.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Google", driver.title)
     #time.sleep(3)
     elemento = driver.find_element_by_xpath(
         "/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input"
     )
     #print("FUNCIONA1")
     #time.sleep(3)
     elemento.send_keys("selenium", Keys.ARROW_DOWN)
예제 #17
0
def test_login_to_jira():
    # driver = webdriver.Chrome('C:\\Users\\Анастасия\\Desktop\\python\\PySample\\chromedriver_win32\\chromedriver.exe')
    driver = webdriver.Chrome(ChromeDriverManager().install())
    driver.get('http://jira.hillel.it:8080/secure/Dashboard.jspa')
    assert "System Dashboard - Hillel IT School JIRA" in driver.title

    driver.find_element_by_id("login-form-username").clear()
    driver.find_element_by_id("login-form-username").send_keys("adikalova")
    driver.find_element_by_id("login-form-password").clear()
    driver.find_element_by_id("login-form-password").send_keys("1234567")
    driver.find_element_by_id("login").submit()

    assert driver.page_source.find('Dashboard')
 def test_Funcion_Explicit_Wait(self):
     driver = self.driver
     driver.get("http://www.facebook.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Facebook - Inicia sesión o regístrate", driver.title)
     try:
         time.sleep(3)
         element = WebDriverWait(driver, 10).until(
         EC.presence_of_element_located((By.NAME, "email"))
         )
         print("Si lo encontro")
     finally:
         driver.quit()
예제 #19
0
 def test_Notificacion_box(self):
     Opciones = Options()
     #enviar argumentos 1 = permitir notificacion, 2 = bloquear notificacion
     Opciones.add_experimental_option(
         "prefs",
         {"profile.default_content_setting_values.notifications", 2})
     driver = self.driver
     driver.maximize_window()
     driver.get("http://developer.mozilla.org/es/docs/web/API/notification")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Notification - Referencia de la API Web | MDN",
                   driver.title)
     time.sleep(3)
예제 #20
0
 def test_boton_radio(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.w3schools.com/howto/howto_css_custom_checkbox.asp")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("How To Create a Custom Checkbox", driver.title)
     time.sleep(3)
     boton_radio = driver.find_element_by_xpath("//*[@id='main']/div[3]/div[1]/input[4]")
     boton_radio.click()
     time.sleep(3)
     boton_radio = driver.find_element_by_xpath("//*[@id='main']/div[3]/div[1]/input[3]")
     boton_radio.click()
     time.sleep(3)
예제 #21
0
 def test_toggle_switch(self):
     driver = self.driver
     driver.implicitly_wait(15)  #pausa segundo
     driver.maximize_window()
     driver.get("https://www.w3schools.com/howto/howto_css_switch.asp")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("How To Create a Toggle Switch", driver.title)
     toggle = driver.find_element_by_xpath("//*[@id='main']/label[1]/div")
     toggle.click()
     print("Funciona")
     time.sleep(3)
     toggle.click()
     time.sleep(3)
 def test_Texto_Imagen(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("http://www.facebook.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Facebook - Inicia sesión o regístrate", driver.title)
     driver.save_screenshot("img2.png")
     time.sleep(3)
     img2 = cv2.imread("img2.png")
     pytesseract.pytesseract.tesseract_cmd = "C:\\Users\\ING\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe"
     print("hasta aqui funciona")
     texto = pytesseract.pytesseract.image_to_string(img2)
     print("hasta aqui funciona")
     print("El texto de la imagen es:\n", texto)
예제 #23
0
 def test_Alert_Simple(self):
     driver = self.driver
     driver.maximize_window()
     driver.get(
         "File:///C:/Users/ING/Desktop/Automation/Automation/Alertas/AlertSimple.html"
     )
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Alerta Simple", driver.title)
     time.sleep(3)
     Alerta_Simple = driver.find_element_by_xpath("/html/body/button")
     Alerta_Simple.click()
     time.sleep(3)
     Alerta_Simple = driver.switch_to_alert()
     Alerta_Simple.dismiss()
     time.sleep(3)
 def test_Descargar_Archivo(self):
     driver = self.driver
     driver.maximize_window()
     driver.get(
         "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_a_download"
     )
     time.sleep(5)
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("Tryit Editor v3.6", driver.title)
     driver.switch_to.frame(
         driver.find_element_by_xpath(
             "/html/body/div[7]/div[4]/div/div/iframe"))
     driver.find_element_by_xpath("/html/body/p[2]/a").click()
     #print("Satisfactorio", Movimiento)
     time.sleep(5)
 def test_Display_Element(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.google.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Google", driver.title)
     time.sleep(3)
     displayelement = driver.find_element_by_xpath(
         "/html/body/div[1]/div[3]/form/div[1]/div[1]/div[3]/center/input[2]"
     )
     print("Cargo el elemento: ", displayelement.is_displayed()
           )  #regresa true o false si ya cargo el elemento
     print("Esta disponible: ", displayelement.is_enabled()
           )  #regresa true o false si el elemento esta disponible
     time.sleep(3)
 def test_Doble_Click(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.ulibertadores.edu.co/estudiantes/")
     time.sleep(5)
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("Estudiantes | Fundación Universitaria Los Libertadores",
                   driver.title)
     ClickDerecho = self.driver.find_element_by_xpath(
         "/html/body/div[2]/div/li[4]/a")
     Movimiento = ActionChains(self.driver)
     #print("Satisfactorio")
     Movimiento.context_click(ClickDerecho).perform()
     #print("Satisfactorio", Movimiento)
     time.sleep(5)
예제 #27
0
 def test_Nueva_Pestaña(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.google.com/intl/es/gmail/about/#")
     time.sleep(5)
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("Google", driver.title)
     siguiente = self.driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/ul[1]/li/div/div/div[1]/div/div[3]/a[1]")
     siguiente.click()
     print("El id siguiente es:\n", self.driver.current_window_handle)
     Manejo = self.driver.window_handles
     i = 1
     for Manejos in Manejo:
         self.driver.switch_to.window(Manejos)
         print("La pagina ", i," es:\n", self.driver.title)
     time.sleep(3)
예제 #28
0
 def test_Hyperlinks(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.w3schools.com/")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("W3Schools Online Web Tutorials", driver.title)
     time.sleep(5)
     #encontrar1 = driver.find_element_by_link_text('Tutorials')
     #encontrar1.click()
     encontrar1 = driver.find_element_by_xpath(
         '//*[@id="navbtn_tutorials"]')
     encontrar1.click()
     time.sleep(3)
     encontrar = driver.find_element_by_link_text('Learn PHP')
     encontrar.click()
     time.sleep(3)
예제 #29
0
 def test_Movimiento_Mouse(self):
     driver = self.driver
     driver.maximize_window()
     driver.get("https://www.ulibertadores.edu.co/estudiantes/")
     time.sleep(5)
     print("Titulo de la aplicación: ", driver.title, "\n")
     print("URL de la aplicación: ", driver.current_url, "\n")
     self.assertIn("Estudiantes | Fundación Universitaria Los Libertadores",
                   driver.title)
     Mouse = self.driver.find_element_by_xpath(
         "//*[@id='menu-item-91829']/a[1]")
     Mouse1 = self.driver.find_element_by_xpath(
         "//*[@id='menu-item-92306']/a[1]")
     Movimiento = ActionChains(self.driver)
     #print("Satisfactorio")
     Movimiento.move_to_element(Mouse).move_to_element(
         Mouse1).click().perform()
     #print("Satisfactorio")
     time.sleep(5)
 def test_Navegar_Entre_Pestañas(self):
     driver = self.driver
     driver.get("http://www.google.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Google", driver.title)
     #time.sleep(3)
     driver.execute_script("window.open('');")
     #print("FUNCIONA")
     #time.sleep(3)
     driver.switch_to.window(driver.window_handles[1])
     #print("FUNCIONA")
     driver.get("http://www.google.com")
     print("Titulo de la aplicación: ", driver.title)
     print("URL de la aplicación: ", driver.current_url)
     self.assertIn("Google", driver.title)
     #print("FUNCIONA")
     #time.sleep(3)
     driver.switch_to.window(driver.window_handles[0])