示例#1
0
    def new_browser_tab(self):
        driver = webdriver.Firefox()
        w = Web(driver)
        w.open_web()

        main_window = driver.current_window_handle
        driver.find_element_by_xpath(Path.new_browser_tab_button).click()
        wait = WebDriverWait(driver, 30)
        wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 "//ul[@id='main-nav']//span[contains(text(),'HOME')]")))
        try:
            rs = driver.execute_script("return document.readyState;")
            print(rs)
            if rs == "complete":
                print("Strona została zładowana")
        except Exception as e:
            print("Cos poszło nie tak")
            print(e)

        after_click_window = driver.window_handles

        for window in after_click_window:
            if window not in main_window:
                driver.switch_to.window(window)
                time.sleep(3)
                driver.execute_script("window.scrollBy(0, 2500);")
                element = driver.find_element_by_xpath(
                    "//span[contains(text(),'Feedback we received from Students')]"
                )
                print(element.text)
                driver.execute_script(
                    "arguments[0].setAttribute('style', arguments[1]);",
                    element, "background:yellow; color: Red;")
示例#2
0
    def my_test(self):
        driver = webdriver.Firefox()
        w = Web(driver)
        w.open_web()

        # x = driver.find_element_by_xpath("//form[@action='https://feedburner.google.com/fb/a/mailverify']//input[@name='email']")

        gbt = SeleniumDriver(driver)
        gbt.getElement(
            "//form[@action='https://feedburner.google.com/fb/a/mailverify']//input[@name='email']",
            "XPATH")

        c = Web(driver)
示例#3
0
    def new_message_window(self):
        driver = webdriver.Firefox()
        w = Web(driver)
        w.open_web()

        main_window = driver.current_window_handle
        driver.find_element_by_xpath(Path.new_message_window).click()
        time.sleep(2)

        afterclick_window = driver.window_handles
        for window in afterclick_window:
            if window not in main_window:
                driver.switch_to.window(window)
                try:
                    check = assert_that(main_window, is_not(window))
                    if check == None:
                        print("Okno zostało otwarte")
                except Exception as exc:
                    print("Błąd!" + str(exc))
                    print(exc)
                driver.close()
                driver.switch_to.window(main_window)

        c = Web(driver)
        c.close_web()
示例#4
0
    def check_website(self):
        driver = webdriver.Firefox()
        website = Web(driver)
        website.open_web()

        get_title = driver.title
        my_title = "Selenium Framework | Practiceform"

        if get_title == my_title:
            print("Wszedłeś na stronę")
            assert_that(get_title, equal_to(my_title))
            screens_url = "C:\\Users\\Grzesiek\\PycharmProjects\\Testowe\\Strona_selenium_testy\\Screens\\Test1_screen.png"
            driver.get_screenshot_as_file(screens_url)
        else:
            ("Coś poszło nie tak")

        print("Test1 - passed!!!!")

        driver.close()
示例#5
0
    def new_browser_window(self):
        driver = webdriver.Firefox()
        website = Web(driver)
        website.open_web()

        parent_window = driver.current_window_handle

        driver.find_element_by_xpath(Path.new_browser_window).click()

        afterclick_window = driver.window_handles
        for window in afterclick_window:
            if window not in parent_window:
                driver.switch_to.window(window)
                driver.maximize_window()
                wait = WebDriverWait(
                    driver, 50,
                    ignored_exceptions=NoSuchElementException).until(
                        EC.element_to_be_clickable(
                            (By.XPATH, "//span[contains(text(),'HOME')]")))
                wait.click()

                element1 = driver.find_element_by_xpath(
                    Path.Selenium_Python_Basic_Tutorial)
                driver.execute_script("arguments[0].click();", element1)
                time.sleep(3)
                check1 = "//strong[contains(text(),'What is Python?')]"
                assert driver.find_element_by_xpath(check1)
                time.sleep(1)

                element2 = driver.find_element_by_xpath(
                    Path.Selenium_Python_Intermediate)
                driver.execute_script("arguments[0].click();", element2)
                time.sleep(3)
                check2 = "//strong[contains(text(),'Test Data')]"
                assert driver.find_element_by_xpath(check2)
                time.sleep(1)

                element3 = driver.find_element_by_xpath(
                    Path.Selenium_Python_Frameworks)
                driver.execute_script("arguments[0].click();", element3)
                time.sleep(3)
                check3 = "//strong[contains(text(),'What are Frameworks?')]"
                driver.find_element_by_xpath(check3)
                time.sleep(1)

                close = Web(driver)
                close.close_web()
示例#6
0
    def contact_us_submit(self):
        driver = webdriver.Firefox()
        website = Web(driver)
        website.open_web()

        cfm = Contact_fields(driver)
        cfm.contact_fields_method("Moje imie", "*****@*****.**", "666",
                                  "Polska", "Moja firma",
                                  "To jest moja wiadomość" * 10)
        time.sleep(3)
        driver.find_element_by_xpath(Path.submit_button).click()
        time.sleep(1)

        print("Test2 - passed")

        c = Web(driver)
        c.close_web()
示例#7
0
    def contact_us_clear(self):
        driver = webdriver.Firefox()
        website = Web(driver)
        website.open_web()

        cfm = Contact_fields(driver)
        cfm.contact_fields_method("Moje imie", "*****@*****.**", "666", "Polska", "Moja firma",
                                  "To jest moja wiadomość" * 30)

        time.sleep(3)

        driver.find_element_by_xpath(Path.clear_button).click()
        time.sleep(1)
        driver.find_element_by_xpath("//a[@class='dt-btn dt-btn-m dt-btn-submit']").click()
        driver.get_screenshot_as_file(
            "C:\\Users\\Grzesiek\\PycharmProjects\\Testowe\\Strona_selenium_testy\\Screens\\Test3.png")

        print("Test3 - passed")

        c = Web(driver)
        c.close_web()