Beispiel #1
0
 def __init__(self, driver):
     self.driver = driver
     self.about_me_header = WebDriverWait(self.driver.instance, 10).until(
         EC.visibility_of_element_located(
             (By.XPATH, "//h1[contains(text(), 'About Me')]")))
     self.about_me_post = WebDriverWait(self.driver.instance, 10).until(
         EC.visibility_of_element_located((By.CLASS_NAME, "entry-content")))
Beispiel #2
0
    def relatorio(self):
        driver = self.driver
        driver.get('https://marketplace.integracommerce.com.br/v2/Order')
        time.sleep(4)
        usuario = driver.find_element_by_id("username")
        usuario.send_keys(self.user)
        first_option = WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located((
                By.XPATH,
                "/html/body/div[1]/div[2]/div/div/div[1]/div/form/div[1]/label"
            )))
        first_option.click()
        password = driver.find_element_by_id("password")
        password.send_keys(self.passw)
        first_option = WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located((
                By.XPATH,
                "/html/body/div[1]/div[2]/div/div/div[1]/div/form/div[1]/label"
            )))
        first_option.click()
        time.sleep(2)
        login = driver.find_element_by_xpath('//*[@id="kc-login"]').click()
        time.sleep(10)
        fecharmodal = WebDriverWait(driver, 15).until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, ".bootbox-close-button")))
        fecharmodal.click()
        time.sleep(3)
        ordens = WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, "#intPedidosV2 > a:nth-child(1)")))
        ordens.click()
        time.sleep(5)
        driver.switch_to.frame(
            driver.find_element_by_css_selector(
                '.container-fluid > iframe:nth-child(1)'))

        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[1]").click()
        time.sleep(5)
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[2]/div/div/div[2]/div/div/div[1]/button[3]"
        ).click()
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[2]/div/div/div[2]/div/div/div[1]/button[3]"
        ).click()
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[2]/div/div/div[2]/div/div/div[2]/div/div/button[8]"
        ).click()
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[2]/div/div/div[2]/div/div/div[2]/div/div/button[1]"
        ).click()
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[2]/div/div/div[2]/div/div/div[2]/div/div/div/div[2]/button[1]"
        ).click()
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/div[2]/div/div/div[2]/div/div/div[2]/div/div/div/div[2]/button[3]"
        ).click()
        data = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/form/button[2]").click()
Beispiel #3
0
 def validate_social_media_links(self):
     twitter_button = WebDriverWait(self.driver.instance, 10).until(
         EC.visibility_of_element_located((
             By.XPATH, "//span[contains(text(), 'Twitter')]")))
     linkedin_button = WebDriverWait(self.driver.instance, 10).until(
         EC.visibility_of_element_located((
             By.XPATH, "//span[contains(text(), 'LinkedIn')]")))
     assert twitter_button.is_displayed()
     assert linkedin_button.is_displayed()
Beispiel #4
0
 def is_visible(self, locator, timeout=10):
     try:
         ui.WebDriverWait(self.driver, timeout).until(
             EC.visibility_of_element_located((By.XPATH, locator)))
         return True
     except TimeoutException:
         return False
def test_optional_feedback(browser, link):
    browser.get(link)
    answer = send_answer()
    WebDriverWait(browser, 7).until(
        EC.visibility_of_element_located((By.CLASS_NAME, "textarea.string-quiz__textarea.ember-text-area.ember-view"))
    )
    text_input = browser.find_element_by_class_name("textarea.string-quiz__textarea.ember-text-area.ember-view")
    text_input.send_keys(str(answer))
    tap_button = browser.find_element_by_class_name("submit-submission")
    tap_button.click()

    hint = WebDriverWait(browser, 5).until(
        EC.visibility_of_element_located((By.CLASS_NAME, "smart-hints__hint"))
    )
    alert = hint.text
    assert alert == "Correct!", f"Alert '''{alert}''' don't match with correct string"
Beispiel #6
0
 def find_css_send(self, selenium, css, number):
     try:
         WebDriverWait(selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.CSS_SELECTOR, css)))
         selenium.find_element_by_css_selector(css).send_keys(number)
     except:
         print("%s元素不可见" % css)
Beispiel #7
0
 def find_id_click(self, selenium, id):
     try:
         WebDriverWait(selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.ID, id)))
         selenium.find_element_by_id(id).click()
     except:
         print("%s元素不可见" % id)
Beispiel #8
0
 def find_name_send(self, selenium, name, number):
     try:
         WebDriverWait(selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.NAME, name)))
         selenium.find_element_by_name(name).send_keys(number)
     except:
         print("%s元素不可见" % name)
Beispiel #9
0
 def find_xpath_send(self, selenium, xpath, number):
     try:
         WebDriverWait(selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.XPATH, xpath)))
         selenium.find_element_by_xpath(xpath).send_keys(number)
     except:
         print("%s元素不可见" % xpath)
 def clickBackIcon(self):
     wait = WebDriverWait(self.driver, 100)
     element = wait.until(
         EC.visibility_of_element_located(
             (By.CSS_SELECTOR, "[data-test-id='backLink']")))
     element.click()
     time.sleep(2)
Beispiel #11
0
 def find_id_send(self, selenium, id, number):
     try:
         WebDriverWait(self, selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.ID, id)))
         selenium.find_element_by_id(id).send_keys(number)
     except:
         print("%s元素不可见" % id)
Beispiel #12
0
 def find_name_click(self, selenium, name):
     try:
         WebDriverWait(selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.NAME, name)))
         selenium.find_element_by_name(name).click()
     except:
         print("%s元素不可见" % name)
Beispiel #13
0
 def find_xpath_click(self, selenium, xpath):
     try:
         WebDriverWait(selenium, 10, 0.5).until(
             EC.visibility_of_element_located((By.XPATH, xpath)))
         selenium.find_element_by_xpath(xpath).click()
     except:
         print("%s元素不可见" % xpath)
 def find_elements(self, *loc):
     try:
         WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(loc))
         return self.driver.find_elements(*loc)
     except NoSuchElementException:
         log.error("未找到元素")
         self.get_img()
 def clicklogOutButton(self):
     wait = WebDriverWait(self.driver, 100)
     element = wait.until(
         EC.visibility_of_element_located(
             (By.CSS_SELECTOR, "[data-test-id='logout']")))
     element.click()
     time.sleep(2)
Beispiel #16
0
    def test_BiziPix_using(self):
        driver = self.driver
        driver.get(self.base_url)
        LoginPage.loginAction(self, 'SellerTestcjd', 'Ss123456')
        time.sleep(3)
        HelperTestBase.reliableClick(self,
                                     "[data-test-id='shoppingListProduct_0']")
        HelperTestBase.reliableClick(self,
                                     "[data-test-id='abstractListProduct_0']")
        HelperTestBase.reliableClick(self, "[data-test-id='BiziPix']")

        wait = WebDriverWait(self.driver, 100)
        cursor = wait.until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, "[data-test-id='cursor']")))
        # img = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "[data-test-id='bizipixImage']")))

        actions = ActionChains(driver)
        actions.move_to_element(cursor)
        actions.click_and_hold(cursor)
        actions.drag_and_drop_by_offset(cursor, 162, -75)
        time.sleep(2)
        actions.drag_and_drop_by_offset(cursor, 60, -80)
        time.sleep(2)
        actions.drag_and_drop_by_offset(cursor, 62, -75)

        actions.perform()
        time.sleep(3)
        HelperTestBase.reliableClick(self, "[data-test-id='bizipixCard']")
        time.sleep(6)
        self.assertIs(
            True,
            HelperTestBase.checkElementPresent(
                self, "[data-test-id='detailBuyNow']"))
 def clickBackButton111(self):
     wait = WebDriverWait(self.driver, 100)
     element = wait.until(
         EC.visibility_of_element_located((
             By.CSS_SELECTOR,
             "body > app-root > div > div > watch-list > div > watch-list-header > header > nav > div.navbar__left > a"
         )))
     element.click()
     time.sleep(2)
 def visibilityOfElementLocated(self,locationType,locatorExpression,*arg):
     '''显示等待页面元素的出现'''
     try:
         element = self.wait.until(
             EC.visibility_of_element_located((
                 self.locationTypeDict[locationType.lower()],
                 locatorExpression)))
     except Exception as e:
         raise e
    def log_in(self, ):
        try:
            # todo: dealing with popup windows
            # cookies popup
            print('\nClosing cookies window ...')
            WebDriverWait(self.driver, 10).until(
                EC.visibility_of_element_located(
                    (By.XPATH, '//div/div/div[2]/button[1]'))).click()
            sleep(1)

        except Exception:
            self.error = True
            print('Unable to close popup window')
        else:
            try:
                with open(self.keys, 'r') as a:
                    keys_dict = json.loads(a.read())
                # Press button to access the login fields
                sleep(1)
                login_button = self.driver.find_element_by_xpath(
                    '//section[2]/div[1]/div/section[2]/a[1]')
                login_button.click()
                sleep(1)

                # todo: switch window
                #  https://sqa.stackexchange.com/questions/13792/how-to-proceed-after-clicking-a-link-to-new-page-in-selenium-in-python
                window_after = self.driver.window_handles[1]
                self.driver.switch_to.window(window_after)
                print('Logging in with username and password ...')

                WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located(
                        (By.XPATH, '//*[@id="username"]')))
                user_name_input = self.driver.find_element_by_xpath(
                    '//*[@id="username"]')
                user_name_input.send_keys(keys_dict['username'][1])
                sleep(1)

                WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located(
                        (By.XPATH, '//*[@id="password"]')))
                password_input = self.driver.find_element_by_xpath(
                    '//*[@id="password"]')
                password_input.send_keys(keys_dict['password'][1])
                sleep(1)
                a.close()

                # user_name_input.submit()
                self.driver.find_element_by_xpath(
                    '//form/div[3]/button').submit()
                sleep(1)

            except Exception as e:
                print(e)
                self.error = True
Beispiel #20
0
 def VerifyShareCount(self):
     WebDriverWait(self.browser, 10).until(
         EC.visibility_of_element_located(
             self.Locator_login_buttons["ShareCount"]))
     shareCount = self.browser.find_element(
         *self.Locator_login_buttons['ShareCount']).text
     count = str(shareCount)
     if (count >= 1):
         print("Share Count has been updated as " + count)
         assert (True)
     else:
         assert (False)
Beispiel #21
0
 def find_element(self, *loc):
     #        return self.driver.find_element(*loc)
     try:
         # 确保元素是可见的。
         # 注意:以下入参为元组的元素,需要加*。Python存在这种特性,就是将入参放在元组里。
         #            WebDriverWait(self.driver,10).until(lambda driver: driver.find_element(*loc).is_displayed())
         # 注意:以下入参本身是元组,不需要加*
         WebDriverWait(self.driver,
                       10).until(EC.visibility_of_element_located(loc))
         return self.driver.find_element(*loc)
     except:
         print("%s 页面中未能找到 %s 元素" % (self, loc))
Beispiel #22
0
 def VerifySuccess(self):
     dd = self.browser.find_element(
         *self.Locator_login_buttons['ShareSuccessMessage']).is_displayed()
     if (dd):
         assert (dd)
     else:
         WebDriverWait(self.browser, 10).until(
             EC.visibility_of_element_located(
                 self.Locator_login_buttons['okeyButton'])).click()
         time.sleep(2)
         self.browser.find_element(
             *self.Locator_login_buttons['CrossButtonAfterError']).click()
         time.sleep(3)
         self.browser.find_element(
             *self.Locator_login_buttons['Public']).click()
Beispiel #23
0
 def VerifySocialShare(self):
     WebDriverWait(self.browser, 10).until(
         EC.visibility_of_element_located(
             self.Locator_login_buttons["Facebook"]))
     facebook = self.browser.find_element(
         *self.Locator_login_buttons['Facebook']).is_displayed()
     assert (facebook)
     ii = self.browser.find_element(
         *self.Locator_login_buttons['Twitter']).is_displayed()
     assert (ii)
     jj = self.browser.find_element(
         *self.Locator_login_buttons['Google']).is_displayed()
     assert (jj)
     kk = self.browser.find_element(
         *self.Locator_login_buttons['Linkdin']).is_displayed()
     assert (kk)
Beispiel #24
0
 def VerifyFileLoad(self):
     driver = webdriver.Chrome('C:\Users\ZAWAR-PC\Desktop\chromedriver.exe')
     window_after = driver.window_handles[0]
     driver.switch_to.window(window_after)
     try:
         WebDriverWait(self.browser, 30).until(
             EC.visibility_of_element_located(
                 self.Locator_login_buttons["FileTitleIncognito"]))
         FileName = self.browser.find_element(
             *self.Locator_login_buttons["FileTitleIncognito"]).text
         ExpectedName = "RenameTest.grid"
         if (FileName == ExpectedName):
             print("Shared File opened in Incognito mood")
             assert (True)
     except:
         print("Shared File is not opened")
         assert (False)
Beispiel #25
0
 def wait_eleVisible(self, loc, timeout=20, poll_frequency=0.5, model=None):
     """
     :param loc:元素定位表达;元组类型,表达方式(元素定位类型,元素定位方法)
     :param timeout:等待的上限
     :param poll_frequency:轮询频率
     :param model:等待失败时,截图操作,图片文件中需要表达的功能标注
     :return:None
     """
     logging.info('{} 等待元素可见:{}'.format(model, loc))
     try:
         start = time.time()
         WebDriverWait(self.driver, timeout, poll_frequency).until(
             EC.visibility_of_element_located(loc))
         end = time.time()
         logging.info('等待时长:%.2f 秒' % (end - start))
     except:
         logging.exception('{} 等待元素可见失败:{}'.format(model, loc))
         # 截图
         self.save_webImgs(model)
         raise
 def wait(self, locator=None):
     element_present = EC.visibility_of_element_located(
         (By.CSS_SELECTOR, locator))
     WebDriverWait(self.driver, 120).until(element_present)
Beispiel #27
0
    def test_01(self):
        driver = self.driver
        self.driver.get("http://intgr-test-2.stage.erp.vseinstrumenti.net/")
        driver.find_element_by_name("_username").click()
        driver.find_element_by_name("_username").clear()
        driver.find_element_by_name("_username").send_keys("ZolotovDA")

        driver.find_element_by_name("_password").click()
        driver.find_element_by_name("_password").clear()
        driver.find_element_by_name("_password").send_keys("@#$WERSDFXCV234")

        driver.find_element_by_xpath(
            "//button[@class='btn btn-vi login-button']").click()

        driver.get(
            "http://intgr-test-2.stage.erp.vseinstrumenti.net/docs/Zayavka_Doc/add/?journal_type=doc_zayavki"
        )
        time.sleep(5)
        driver.switch_to_alert().accept()
        time.sleep(1)

        driver.find_element_by_id("newContFacePhone").click()
        driver.find_element_by_id("newContFacePhone").send_keys("9058680002")
        driver.find_element_by_id("contFaceSurname").click()
        driver.find_element_by_name("kontrSelected").click()
        driver.find_element_by_id("chooseFoundContractorButton").click()
        print(driver.current_window_handle)
        driver.find_element_by_id("addNomenclatureBtn").click()

        base_window = print(driver.current_window_handle
                            )  # CDwindow-415AACC4894338D1E80DD585682E0AFB

        handles = driver.window_handles

        for handle in handles:
            driver.switch_to.window(handle)
            print(driver.title)

        driver.find_element_by_id("nom_id").click()
        driver.find_element_by_id("nom_id").send_keys("15791387")
        print(driver.current_window_handle)
        # x = driver.current_window_handle
        # print(x)

        element = WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located((By.XPATH, "//td[4]//input[1]")))
        element.click()

        time.sleep(5)

        # работа с фреймом
        # iframe_form = driver.find_element_by_id("searchResults") инициализация фрейма в переменную

        driver.switch_to.frame(driver.find_element_by_id("searchResults"))
        driver.find_element_by_xpath(
            "//*[@type='button'][@value='Добавить']").click()
        driver.switch_to.default_content()

        print(driver.window_handles)
        print(driver.current_window_handle)
        driver.close()

        # print(driver.current_window_handle)

        time.sleep(10)
 def clickAndWait(self, locator=None):
     wait = WebDriverWait(self.driver, 100)
     element = wait.until(
         EC.visibility_of_element_located((By.CSS_SELECTOR, locator)))
     element.click()
     time.sleep(2)
Beispiel #29
0
    def esperar_elemento(self, locator, MyTextElement=None):
        Get_Entity = Functions.get_entity(self, locator)

        if Get_Entity is None:
            return print("No se encontro el Valor en el Json definido")

        else:
            try:
                if self.json_GetFieldBy.lower() == "id":
                    wait = WebDriverWait(self.driver, 20)  #TIEMPO DE ESPERA
                    wait.until(
                        EC.visibility_of_element_located(
                            (By.ID, self.json_ValueToFind)))
                    wait.until(
                        EC.element_to_be_clickable(
                            (By.ID, self.json_ValueToFind)))
                    print(u"Esperar_Elemento: Se visualizo el elemento " +
                          locator)
                    return True

                if self.json_GetFieldBy.lower() == "name":
                    wait = WebDriverWait(self.driver, 20)
                    wait.until(
                        EC.isibility_of_element_located(
                            (By.NAME, self.json_ValueToFind)))
                    wait.until(
                        EC.isibility_of_element_located(
                            (By.NAME, self.json_ValueToFind)))
                    print(u"Esperar_Elemento: Se visualizo el elemento " +
                          locator)
                    return True

                if self.json_GetFieldBy.lower() == "xpath":
                    wait = WebDriverWait(self.driver, 20)
                    if MyTextElement is not None:
                        self.json_ValueToFind = self.json_ValueToFind.format(
                            MyTextElement)
                        print(self.json_ValueToFind)

                        wait.until(
                            EC.visibility_of_element_located(
                                (By.XPATH, self.json_ValueToFind)))
                        wait.until(
                            EC.element_to_be_clickable(
                                (By.XPATH, self.json_ValueToFind)))
                        print(u"Esperar_Elemento: Se visualizo el elemento " +
                              locator)
                        return True

                if self.json_GetFieldBy.lower() == "link":
                    wait = WebDriverWait(self.driver, 20)
                    wait.until(
                        EC.visibility_of_element_located(
                            (By.LINK_TEXT, self.json_ValueToFind)))
                    wait.until(
                        EC.EC.element_to_be_clickable(
                            (By.PARTIAL_LINK_TEXT, self.json_ValueToFind)))
                    print(u"Esperar_Elemento: Se visualizo el elemento " +
                          locator)
                    return True
            except TimeoutError:
                print(u"Esperar_Elemento: No presente " + locator)
                Functions.tearDow(self)
            except NoSuchElementException(self):
                print(u"Esperar_Elemento: No presente " + locator)
 def waitSettingsButton(self):
     element_present = EC.visibility_of_element_located(
         (By.CSS_SELECTOR, "[data-test-id='settingsLink']"))
     WebDriverWait(self.driver, 100).until(element_present)