Пример #1
0
    def add_file(self, path, node_url=None):
        """Add a file. Assumes that the test class is harnessed to a project"""
        node_url = node_url or self.project_url
        self.goto('files', node_url=node_url)

        wait(self.driver, 3).until(
            ec.visibility_of_element_located(
                (By.CSS_SELECTOR, 'div.container h3 a#clickable.dz-clickable')
            )
        )

        self.driver.execute_script('''
            $('input[type="file"]').attr('style', "");
        ''')

        #with WaitForFileUpload(self.driver, wait=5):

        ## Upload files
        #self.driver.find_element_by_css_selector(
        #    'div.container h3 A#clickable.dz-clickable'
        #).click()

        wait(self.driver, 3).until(
            ec.visibility_of_element_located(
                (By.CSS_SELECTOR, 'input[type="file"]')
            )
        )
        # Find file input
        field = self.driver.find_element_by_css_selector('input[type="file"]')

        # Enter file into input
        field.send_keys(path)
Пример #2
0
def go():
    # to keep browser open by passing in below option
    ops = Options()
    ops.add_experimental_option('detach', True)
    browser = webdriver.Chrome(ChromeDriverManager().install(),
                               chrome_options=ops)

    browser.get("https://www.seleniumeasy.com/test/bootstrap-modal-demo.html")
    time.sleep(2)
    #popup 2nd modal
    btn_modal = browser.find_elements_by_link_text("Launch modal")
    btn_modal[1].click()

    wait(browser,
         10).until(EC.visibility_of_element_located((By.ID, "myModal")))
    dialog2_btn = browser.find_elements_by_css_selector("#myModal .btn")
    #pop up nested modal
    dialog2_btn[0].click()

    wait(browser,
         10).until(EC.visibility_of_element_located((By.ID, "myModal2")))
    dia_nested_btn = browser.find_elements_by_css_selector("#myModal2 .btn")
    #close
    time.sleep(1)
    dia_nested_btn[0].click()
    #popup again
    dialog2_btn[0].click()

    #save and close
    time.sleep(1)
    dia_nested_btn[1].click()
    #close 2nd modal
    dialog2_btn[1].click()
Пример #3
0
def print_articles(driver, nb_of_articles):
    articles_printed = 0
    # CLick on first article, then use arrows to iterate
    wait(driver, 10).until(
        EC.visibility_of_element_located((
            By.XPATH,
            '/html/body/div[2]/div[8]/div[2]/div[1]/div[1]/div[1]/div/div/div[3]/div/div[1]/div[1]/div/div[2]/div[2]'
        ))).click()

    for i in range(nb_of_articles):
        try:
            print(f"Showing article {i}")
            wait(driver, 10).until(
                EC.visibility_of_element_located(
                    (By.XPATH,
                     '/html/body/div[2]/div[5]/div/div/div[3]/div[2]/div/div'
                     ))).click()

            # Print content
            driver.execute_script('window.print();')

            print(f'{articles_printed} articles printed.')

        except:
            print(f'Could not print article {i}')
            break
 def pop_up_apperears_tab_off_it(self):
     wait(self.driver, 10).until(EC.url_changes('yahoo.com'))
     current_tab = self.driver.current_window_handle
     # time.sleep(2) is needed to give the pop up time to appear. Outside of
     # using a pop up selenium tool is the only way to handle this.
     time.sleep(2)
     self.driver.switch_to.window(current_tab)
Пример #5
0
def type_in(context, element, text):
    try:
        wait(context.driver, 10).until(
            expected_conditions.visibility_of_element_located(
                element)).send_keys(text)
    except:
        print(f'Error with typing in {element}')
Пример #6
0
    def test_create_event_on_calendar_page(self):
        profile = Profile.objects.get(user=User.objects.get(
            username="******"))
        calendar_url = self.live_server_url + reverse("calendar")
        self.browser.get(calendar_url)
        wait(self.browser, 20).until(
            EC.element_to_be_clickable(
                (By.CLASS_NAME, "add_event_for_user"))).click()

        start_date = datetime.now(tz=timezone.utc).astimezone()
        end_date = datetime.now(tz=timezone.utc).astimezone() + timedelta(
            days=1)

        title = self.browser.find_element_by_css_selector("input#title")
        start_event = self.browser.find_element_by_css_selector(
            "input#start_event")
        self.clear_text(start_event)
        end_event = self.browser.find_element_by_css_selector(
            "input#end_event")
        notes = self.browser.find_element_by_css_selector("input#notes")
        # user id auto setup (value in hidden input)
        submit_btn = self.browser.find_element_by_css_selector(
            "input#submit-event")

        title.send_keys("test")
        start_event.send_keys(datetime.strftime(start_date, "%Y-%m-%d %H:%M"))
        end_event.send_keys(datetime.strftime(end_date, "%Y-%m-%d %H:%M"))
        notes.send_keys("test")
        submit_btn.send_keys(Keys.ENTER)
        time.sleep(2)
        count_events = Calendar.objects.filter(user=profile).count()
        self.assertEqual(1, count_events)
 def hover_over_profile_menu(self):
     profile_menu_loc = (By.XPATH, '//label[@id="ybarAccountMenuOpener"]')
     wait(self.driver,
          15).until(EC.visibility_of_element_located(profile_menu_loc))
     profile_menu_element = self.driver.find_element(*profile_menu_loc)
     ActionChains(
         self.driver).move_to_element(profile_menu_element).perform()
def otp_next(email, password):
    sleep(5)
    # try:#select2-drop > ul > li.select2-results-dept-0.select2-result.select2-result-selectable.select2-highlighted
    browser.save_screenshot("GET_OTP_BEFORE_SATU.png")
    try:
        browser.save_screenshot("GET_OTP_BEFORE_DUA.png")
        wait(browser, 1).until(
            EC.element_to_be_clickable((
                By.CSS_SELECTOR,
                "body > table:nth-child(16) > tbody > tr > td:nth-child(2) > table:nth-child(1) > tbody > tr > td:nth-child(2) > form > table.th > tbody > tr:nth-child(1) > td:nth-child(3) > a > span"
            ))).click()
        print(f"[*] [ {email} ] Open Email")
    except:

        print(f"[*] [ {email} ] Trying to Open Email")
        tsest = wait(browser, 5).until(
            EC.element_to_be_clickable((
                By.XPATH,
                "/html/body/table[2]/tbody/tr/td[2]/table[1]/tbody/tr/td[2]/form/table[2]/tbody/tr[1]/td[3]/a/span"
            )))
        tsest.send_keys(Keys.ENTER)

    extract_otp(email, password)
    print(f"[*] [ {email} ] OTP: {filter_otp} ")
    browser.close()
    browser.switch_to.window(browser.window_handles[0])
    sleep(0.5)
    input_otp(email, password, filter_otp)
def input_otp(email, password, filter_otp):
    print(f"[*] [ {email} ] Go To Input OTP")
    enter_otp = wait(browser, 15).until(
        EC.presence_of_element_located((By.XPATH, '//*[@id="code"]')))

    sleep(0.5)
    enter_otp.send_keys(filter_otp)
    sleep(0.5)
    browser.save_screenshot("INPUT_OTP.png")
    try:
        wait(browser, 15).until(
            EC.element_to_be_clickable(
                (By.XPATH, '//*[@id="login-submit"]/span/span/span'))).click()
        print(f"[*] [ {email} ] Success Input OTP")
    except:
        try:
            browser.refresh()
            enter_otp.send_keys(filter_otp)
            sleep(1)
            wait(browser, 15).until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     '//*[@id="login-submit"]/span/span/span'))).click()
            print(f"[*] [ {email} ] Success Input OTP")
        except:
            enter_otp.send_keys(Keys.ENTER)
    try:
        set_username(email, password)
    except:
        browser.quit()
Пример #10
0
def find_and_click_iframe_elem(selector):
    wait(driver,
         300).until(EC.frame_to_be_available_and_switch_to_it("game-frame"))
    alley_button = driver.find_element_by_css_selector(selector)
    time.sleep(5)
    alley_button.click()
    driver.switch_to.default_content()
    def __init__(self):
        try:
            with open('config.json', 'r') as f:
                self.config = json.load(f)
            if self.config['windowMode'] == True:
                self.browser = webdriver.Firefox(
                    executable_path=r'.\geckodriver.exe')

            else:
                options = Options()
                options.add_argument('-headless')
                self.browser = webdriver.Firefox(
                    executable_path=r'.\geckodriver.exe', options=options)

            print('Otwieram stronę')
            self.browser.get('https://portal.librus.pl/rodzina')
            print('Otworzyłem stronę')
            wait(self.browser, 10).until(
                cond.element_to_be_clickable(
                    (By.XPATH,
                     '/html/body/nav/div/div[1]/div/div[2]/a[3]'))).click()
            wait(self.browser, 10).until(
                cond.element_to_be_clickable((
                    By.XPATH,
                    '/html/body/nav/div/div[1]/div/div[2]/div/a[2]'))).click()
            self.signIn()
            self.checkingIfMessagesExist()
        except KeyboardInterrupt:
            self.browser.quit()
Пример #12
0
 def atc_and_checkout(self):
     while not self.did_submit:
         for xpath_step in self.xpath_sequence:
             for attempt in range(self.retry_attempts + 1):
                 try:
                     wait(self.browser, 5).until(
                         EC.presence_of_element_located(
                             (By.XPATH, xpath_step['path'])))
                     self.process_step(xpath_step)
                     break
                 except:
                     if xpath_step['optional']:
                         break
                     elif attempt == self.retry_attempts:
                         if not self.check_stock(new_tab=True):
                             self.status_signal.emit(
                                 create_msg(
                                     'Product is out of stock. Resuming monitoring.',
                                     'error'))
                             return
                         else:
                             self.status_signal.emit(
                                 create_msg(
                                     'Encountered unknown page while product in stock. Quitting.',
                                     'error'))
                             self.failed = True
                             return
                     self.process_interruptions(attempt=attempt)
Пример #13
0
 def ClickNewTab(self):
     wait(self.driver, 10).until(
         EC.visibility_of_element_located((By.ID, (self.newtabbutton_id))))
     self.driver.find_element_by_id(self.newtabbutton_id).click()
     self.driver.switch_to.window(self.driver.window_handles[1])
     time.sleep(2)
     self.driver.switch_to.window(self.driver.window_handles[0])
def recursivetable_old(wait_element, escape_element=None, link=None, tab=None):
    try:
        wait_until(Text(wait_element).exists)
    except:
        pass
    if wait_element=='DUE DATE & TIME' and Button('Load More').exists:
        click(Button('Load More'))
        try:
            wait(browser, 10).until(EC.invisibility_of_element_located((By.CLASS_NAME, '_dxnw6v3')))
        except:
            print('collecting limited assignment details')
    if escape_element is not None:
        if Text(escape_element).exists and link is None and not Text(wait_element).exists:
            print('blank activity')
            return pd.DataFrame(columns=[escape_element])
    n = Button('Next')
    if n.exists() and n.is_enabled():
        table_list = []
        while n.is_enabled():
            wait_until(Text(wait_element).exists)
            try:
                table = get_table(link=link, tab=tab)
            except:
                time.sleep(3)
                table = get_table(link=link, tab=tab)
            table_list.append(table)
#             links_list.extend(links)
            click(n)
            n = Button('Next')
        table_list.append(get_table(tab=tab))
        table = pd.concat(table_list)
    else:
        table = get_table(link=link, tab=tab)
    return table
Пример #15
0
    def run(self):
        #打开网页
        self.driver.get(self.url)
        #登录
        self.login()
        #从多少页开始爬取
        spider_page = int(input("输入从第几页开始爬取,输入整数:"))
        if spider_page>1:
            self.continue_spider(spider_page)
        while True:
            wait(self.driver,timeout=10).until(EC.presence_of_all_elements_located((By.XPATH,"//div[@class='pager_container']/span[last()]")))
            source = self.driver.page_source
            # print(source)
            self.parse_page_url(source)

            next_page = self.driver.find_element_by_xpath("//div[@class='pager_container']/span[@action='next']")
            adv_page= self.driver.find_element_by_xpath("//div[@class='body-btn']")

            if adv_page.text:
                adv_page.click()

            if 'pager_next pager_next_disabled' in next_page.get_attribute("class"):
                print("爬取完成")
                break
            else:
                next_page.click()
                time.sleep(1)
Пример #16
0
    def monitor(self):
        self.in_stock = False
        self.browser.get(self.product)
        print(self.product)
        wait(self.browser, self.TIMEOUT_LONG).until(
            lambda _: self.browser.current_url == self.product)

        while not self.img_found:
            try:
                if not self.img_found:
                    product_img = self.browser.find_elements_by_class_name(
                        'slideDeckPicture')[0].find_element_by_tag_name("img")
                    self.image_signal.emit(product_img.get_attribute("src"))
                    self.product_image = product_img.get_attribute("src")
                    self.img_found = True
            except Exception as e:
                continue

        while not self.in_stock:
            self.in_stock = self.check_stock()
            if self.in_stock:
                continue
            else:
                self.status_signal.emit(
                    create_msg("Waiting on Restock", "normal"))
                time.sleep(
                    random_delay(self.monitor_delay,
                                 settings.random_delay_start,
                                 settings.random_delay_stop))
                self.browser.refresh()
 def click_sign_in_button(self):
     sign_in_button_loc = (By.LINK_TEXT, 'Sign in')
     wait(self.driver,
          15).until(EC.element_to_be_clickable(sign_in_button_loc))
     url_before_click = self.driver.current_url
     self.driver.find_element(*sign_in_button_loc).click()
     wait(self.driver, 15).until(EC.url_changes(url_before_click))
Пример #18
0
def is_visible():
    try:
        wait(driver, 10).until(
            EC.presence_of_element_located((By.ID, 'errorMessagesSub')))
        return True
    except TimeoutException:
        return False
def phone(update, context):
    if "use" in update.message.text.lower() and checkifregistered(theuserid):
        global wantsavedinfo
        wantsavedinfo = True
        checkifregistered(theuserid)
        from sqlitedb import savednumber

        user.send_keys(str(savednumber))
        time.sleep(random.randint(3, 10))
        wait(driver, 20).until(EC.element_to_be_clickable(
            (By.ID, "login-btn"))).click()
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text="Send me the code, use text")
        return VERIFY
    else:
        wantsavedinfo = False
        context.bot.send_message(
            chat_id=update.effective_chat.id,
            text="Please type anything and send it to pass to the next process",
            reply_markup=ReplyKeyboardMarkup([["okay"]],
                                             one_time_keyboard=True))

    phonenumberarray = []
    for i in update.message.text:
        if i in "0123456789":
            phonenumberarray.append(i)
    global goodphonenum
    goodphonenum = "".join(phonenumberarray)
    return ASK_ABOUT_PHONE
Пример #20
0
    def test_register_user(self):
        logger.info("test_register_user")
        driver = self.driver
        driver.get(self.URL)

        try:
            wait(driver, 5).until(EC.visibility_of_element_located((By.ID, 'SignInAccountBtn')))
            self.assertIn("Okta GambCorp Demo", driver.title)

            loginPagesMenuButton = driver.find_element_by_xpath("//*[@id='nav-link-login']").click()
            apiPagesMenuButtonButton = driver.find_element_by_xpath("//*[@id='nav-link--pages--api']").click()
            regMenuButtonButton = driver.find_element_by_xpath("//*[@id='nav-submenu--pages--api']/li[2]/a").click()

            set_field_value(driver, "FullNameInput", self.firstName + ' ' + self.lastName)
            set_field_value(driver, "EmailInput", self.email)
            set_field_value(driver, "PasswordInput", self.PWD)

            super().save_screenshot(__name__, "00", self.email, "pre-submission")
            regButton = driver.find_element_by_id("SignupSubmitButton").click()
            wait(driver, 5).until(EC.visibility_of_element_located((By.ID, 'SignupSubmitButton')))

            super().save_screenshot(__name__, "01", self.email, "post-submission")
        except TimeoutException as exc:
            logger.error("Timed out: " + __name__, exc_info=True)
            super().save_screenshot(__name__, "01", self.email, "error")
        driver.switch_to.default_content()
Пример #21
0
 def run_sel_lazyloading(self, split, sleep=10):
     # Get the current number of rows
     current_rows_number = len(
         self.driver.find_elements_by_class_name(
             'explorerCard__explorerCard--3Q7_0'))
     total_number = int(
         self.driver.find_elements_by_css_selector(
             '.querySummary__querySummary--39WP2')[0].text.split('Showing ')
         [1].split(split)[0])
     print("Total Number: ", total_number)
     while current_rows_number < total_number:
         # Scroll down to make new XHR (request more table rows)
         self.driver.find_element_by_tag_name('body').send_keys(Keys.END)
         try:
             self.driver.set_window_position(0, -1000)
             # Wait until number of rows increased
             time.sleep(sleep)
             wait(self.driver, 50).until(lambda drive: len(
                 self.driver.find_elements_by_class_name(
                     'explorerCard__explorerCard--3Q7_0')) >
                                         current_rows_number)
             # Update variable with current rows number
             current_rows_number = len(
                 self.driver.find_elements_by_class_name(
                     'explorerCard__explorerCard--3Q7_0'))
             if current_rows_number % 200 == 0:
                 print("Curr Row Number: ", current_rows_number)
         # If number of rows remains the same after 5 seconds passed, break the loop
         # as there no more rows to receive
         except TimeoutException:
             break
 def click_search_button(self):
     search_button_loc = (By.XPATH, '//input[@type="submit"]')
     wait(self.driver,
          15).until(EC.element_to_be_clickable(search_button_loc))
     url_before_click = self.driver.current_url
     self.driver.find_element(*search_button_loc).click()
     wait(self.driver, 15).until(EC.url_changes(url_before_click))
Пример #23
0
 def do_login(self):
     self._driver.get(FBModel.MESSAGES_PAGE)
     self._driver.implicitly_wait(2)
     title = self._driver.title
     wait(self._driver, 120).until_not(EC.title_is(title))
     self._login_success = 'messenger' in self._driver.title.lower()
     return self._login_success
Пример #24
0
def fetch_query(query: str,
                number_of_images: int,
                query_scrapper,
                silence=True):
    # Definimos un proveedor de imagenes
    google_images = "https://www.google.com/search?safe=off&site=&tbm=isch&source=hp&q={q}&oq={q}&gs_l=img"
    query_scrapper.get(google_images.format(q=query))

    # Bajamos hasta el final del domento
    scroll(query_scrapper)

    # Recogemos las urls
    res = query_scrapper.find_elements(By.CSS_SELECTOR, 'img.Q4LuWd')
    wait(scrapper, 20)

    # Capturamos las URL de cada imagen
    urls = get_urls(res, query_scrapper)

    # Mostramos la cantidad de imagenes
    if silence == False:
        print(
            "Se han encontractrado",
            len(urls),
            " imagenes que coinciden con tu patrón de busqueda, tomaremos solo ",
            number_of_images,
            end='\n')

    # De los links sacamos solo la cantidad requerida
    images = []
    while len(images) <= number_of_images:
        choosen = choice(list(urls))
        if choosen not in images:
            images.append(choosen)

    return images
Пример #25
0
def click(context, element):
    try:
        wait(context.driver, 10).until(
            expected_conditions.visibility_of_element_located(
                element)).click()
    except:
        print(f'Cant click {element}')
Пример #26
0
    def test_edit_existing_item(self):
        #Go to the last item of the list, add a word at the end of description and confirm that it was added successfully
        try:
            btn_groups = wait(self.driver, 10).until(
                EC.presence_of_all_elements_located(
                    (By.CLASS_NAME, "btn-group")))

            num_items = len(btn_groups)
            btn_group_last_ele = btn_groups[num_items - 1]
            btn_edit = btn_group_last_ele.find_elements_by_class_name('btn')[0]
            btn_edit.click()

            new_word = "EDITED"
            description = self.driver.find_elements_by_class_name(
                "story").pop().text + new_word
            input = self.driver.find_elements_by_class_name("form-control")[1]
            input.send_keys(new_word)
            btn = wait(self.driver, 10).until(
                EC.element_to_be_clickable((By.CLASS_NAME, "btn-primary")))
            btn.click()
            time.sleep(3)
            h1 = self.driver.find_element_by_tag_name("h1").text

            self.assertEqual(
                self.driver.find_elements_by_class_name("story").pop().text,
                description)
            assert str(num_items) in h1
        finally:
            pass
Пример #27
0
	def login(self):

		try:
			self.print_log_message('Navigating to %s' % (self.deviant_login))
			self.bot_browser.get(self.deviant_login)

		except Exception as e:
			self.print_log_message('Exception Occured: %s...retrying' % (str(e)), False)
			self.print_log_message('Navigating to %s' % (self.deviant_login))
			self.bot_browser.get(self.deviant_login)

		self.print_log_message('Trying to find element')
		login_page_form = self.bot_browser.find_element_by_id('login')
		login_page_title = self.bot_browser.title
		login_page_username = self.bot_browser.find_element_by_id('login_username')
		login_page_password = self.bot_browser.find_element_by_id('login_password')

		self.print_log_message("Logging In")

		login_page_username.send_keys(self.credentials[0])
		login_page_password.send_keys(self.credentials[2])

		login_page_form.submit()

		wait(self.bot_browser, 15).until_not(EC.title_is(login_page_title))
Пример #28
0
def gammal_dum_kod(driver, frågor):
    for fråga in frågor:
        print("-----------------------------###---------------------------")
        # print(fråga.text)
        # knappar = fråga.find_elements_by_css_selector('div[aria-label="yes"]')

        # knappar = fråga.find_elements_by_tag_name("input")
        # print(knappar[0].text)
        # knappar[0].parent.parent.click()
        # time.sleep(0.5)

        min_knapp = fråga.find_element_by_class_name("fNHEA_bOnW")
        print(min_knapp.text)
        min_knapp.click()
        time.sleep(T_V_KORT)

    time.sleep(T_KORT)
    wait(driver, 10).until(
        EC.presence_of_element_located(
            (By.CSS_SELECTOR, 'button[data-automation="sdk-submit-button"]')))
    färdig_knapp = driver.find_element_by_css_selector(
        'button[data-automation="sdk-submit-button"]')
    färdig_knapp.click()
    time.sleep(T_KORT)
    wait(driver, 10).until(
        EC.presence_of_element_located(
            (By.CSS_SELECTOR,
             'button[data-automation="sdk-confirmation-modal-confirm"]')))

    rly_färd_knapp = driver.find_element_by_css_selector(
        'button[data-automation="sdk-confirmation-modal-confirm"]')
    rly_färd_knapp.click()

    wait.sleep(3)
    return
Пример #29
0
def extract_addonList(driver):
    """
    This function will extract all addons' names and urls. Chrome extensions
    page shows all addons in 1 page, but only show next addons when scrolling
    to the end of the page. This script also stimulates the scrolling action
    to get full list of addons.
    """

    # Try to scroll until the end of page, then wait for page load
    addonCount = 0

    while True:

        # Wait for the page to finish loading, then extract all addons' names and links
        loadingCircle = driver.find_element_by_css_selector('.h-a-Kd.a-Hd-mb')
        if loadingCircle.is_displayed():
            wait(driver, 30).until(
                EC.invisibility_of_element_located(
                    (By.CSS_SELECTOR, '.h-a-Kd.a-Hd-mb')))

        addonItemList = driver.find_elements_by_css_selector('.h-Ja-d-Ac.a-u')

        # Scroll to last addon item
        if len(addonItemList) > 0:
            lastAddon = addonItemList[-1]
            driver.execute_script("return arguments[0].scrollIntoView();",
                                  lastAddon)
            #sleep(3) # Wait for the page to load

        # Click on "See other results" if any
        seeOther = driver.find_element_by_css_selector('.h-a-Hd-mb.a-Hd-mb')
        if seeOther.is_displayed(): click_wrapper(seeOther)

        # Check condition to exit the while loop
        if len(addonItemList) > addonCount:
            addonCount = len(addonItemList)  # Update count
        else:
            break  # End while loop

    # Loop through all addons, extract names and urls
    addonNameList = []
    addonURLList = []

    for addonItem in addonItemList:
        addonNameList.append(
            addonItem.find_element_by_css_selector('.a-na-d-w').text.strip())
        addonURLList.append(addonItem.get_attribute('href'))

    # Construct result table
    addonTb = pd.DataFrame(
        {
            'addon_name': pd.Series(addonNameList),
            'addon_url': pd.Series(addonURLList)
        },
        columns=['addon_name', 'addon_url'])

    # Add search_rank
    addonTb['search_rank'] = addonTb.index + 1

    return addonTb
Пример #30
0
    def login(self):
        self.status_signal.emit(create_msg("Logging In..", "normal"))

        self.browser.get("https://www.gamestop.com")

        wait(self.browser, self.LONG_TIMEOUT).until(
            EC.element_to_be_clickable((By.LINK_TEXT, "MY ACCOUNT")))
        self.browser.find_element_by_link_text('MY ACCOUNT').click()

        wait(self.browser, self.LONG_TIMEOUT).until(
            EC.element_to_be_clickable((By.ID, "signIn"))).click()

        wait(self.browser, self.LONG_TIMEOUT).until(
            EC.element_to_be_clickable((By.ID, "login-form-email")))

        email = self.browser.find_element_by_id("login-form-email")
        email.send_keys(settings.gamestop_user)

        wait(self.browser, self.LONG_TIMEOUT).until(
            EC.element_to_be_clickable((By.ID, "login-form-password")))

        password = self.browser.find_element_by_id("login-form-password")
        password.send_keys(settings.gamestop_pass)

        time.sleep(
            1
        )  # slight delay for in-between filling out login info and clicking Sign In

        wait(self.browser, self.LONG_TIMEOUT).until(
            EC.element_to_be_clickable(
                (By.XPATH, '//*[@id="signinCheck"]/button')))
        sign_in_btn = self.browser.find_element_by_xpath(
            '//*[@id="signinCheck"]/button')
        sign_in_btn.click()
Пример #31
0
    def process_magnaI(self):
        is_assault_time = self.driver.find_element_by_class_name("prt-assault-time").is_displayed()
        self.driver.find_elements_by_class_name("prt-list-contents")[1].click()

        wait(self.driver,
             30).until(ec.visibility_of_element_located((By.CLASS_NAME, "btn-select-pair-quest")))
        self.driver.find_elements_by_class_name("btn-select-pair-quest")[1].click()
        self.utils.wait_and_click_element_by_class_name("btn-offer")

        time.sleep(1)
        if len(self.driver.find_elements_by_class_name("use-item-num")):
            self.use_elixir_half()

        self.select_supporter_stone()
        self.utils.wait_and_click_element_by_class_name("btn-usual-ok")
        self.wait_until_battle_start()
        self.summon()
        if self.enemy == "シュヴァリエ":
            # TODO: 奥義OFF
            self.attack()
        self.treasure_hunt()
        if self.enemy == "シュヴァリエ":
            self.attack()
            # TODO: 奥義ON
        # TODO: 召喚石を使う
        if is_assault_time:
            if self.use_debuff:
                self.debuff()
            self.attack()
        self.auto_battle()
        self.battle_result()
Пример #32
0
 def get_element(self, css):
     return wait(
         driver=self.driver,
         timeout=5
     ).until(
         method=ec.visibility_of_element_located(
             (By.CSS_SELECTOR, css)
         )
     )
Пример #33
0
def signin(web, username, password):
    """
    Sign in with `username` and `password`
    Returns cookies after signed-in
    """
    web.get(SIGNIN_URL)

    email = wait(web, TIMEOUT).until(
        EC.presence_of_element_located((By.ID, "signin-email")))
    email.send_keys(username)

    pwd = web.find_element_by_id('signin-password')
    pwd.send_keys(password)

    btn = web.find_element_by_class_name('coursera-signin-button')
    btn.click()

    wait(web, TIMEOUT).until(EC.title_contains('Your Courses'))

    return web.get_cookies()
Пример #34
0
 def _wait_clickable(self, by):
     w = wait(self._driver, UI_MAX_IMPLICIT_TIMEOUT)
     return w.until(EC.element_to_be_clickable(by))
Пример #35
0
 def _wait_condition(self, condition: Callable[[WebDriver], bool]):
     w = wait(self._driver, UI_MAX_IMPLICIT_TIMEOUT)
     return w.until(condition)
Пример #36
0
home = "http://rera.karnataka.gov.in/home"
search = "http://rera.karnataka.gov.in/search"

seperator = ", "

# Start process
file = open(state, 'w+')
driver = webdriver.Chrome()
driver.get(home)
try:
    # time.sleep(1)
    # closeButton = wait(driver, 2).until(EC.presence_of_element_located((By.CLASS_NAME,"close")))
    # closeButton.click();
    time.sleep(1)
    assert home in driver.current_url
    searchButton = wait(driver, 2).until(EC.presence_of_element_located((By.CSS_SELECTOR,"span.input-group-addon > button")))
    # time.sleep(2)
    searchButton.click()
    wait(driver, 2).until(EC.url_contains(search))
    action = ActionChains(driver)
    title = "name, address, regNo, date_of_registration, type_of_registration, contact_number, email_address"
    while True:
        rowSearchList = driver.find_elements_by_css_selector("div.row.search_result_list")
        for row in rowSearchList:
            details = str()
            name = row.find_element_by_tag_name("h1").text
            parah = row.find_elements_by_tag_name("p")
            address = parah[0].text
            regNo = parah[1].text
            content = row.find_element_by_css_selector("div.table-responsive").find_elements_by_tag_name("td")
            date_of_registration = content[0].text
Пример #37
0
 def _wait_gone(self, by):
     w = wait(self._driver, UI_MAX_IMPLICIT_TIMEOUT)
     return w.until(lambda _driver: self._element_missing(self._driver, by))
Пример #38
0
from selenium import webdriver
Пример #39
0
    def test_assertTitle(self):    
    ## Test
        wait(driver, 10).until(lambda driver: driver.find_element_by_xpath(flightsTabLoc)).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, flightOnlyLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, roundTripLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, nonStopOnlyLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, departCityLoc))).send_keys(departCityInput)
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, arriveCityLoc))).send_keys(arriveCityInput)
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, departDateLoc))).send_keys(departDateInput)
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, returnDateLoc))).send_keys(returnDateInput)
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, numAdultsLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, numAdultsOneLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, numChildLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, numChildZeroLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, cabinClassLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, cabinClassEcoLoc))).click()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, airLineLoc))).clear()
        wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, searchFlightsLoc))).click()

        mainWindowHandle = driver.window_handles
        # print ("main Window handle: {}".format(mainWindowHandle))
        allWindowsHandlesList = driver.window_handles
        # print ("all window handles: {}".format(allWindowsHandlesList))
        for handle in allWindowsHandlesList:
            if handle != mainWindowHandle[0]:
                driver.switch_to.window(handle)
                driver.close()
                break
Пример #40
0
load_time = 1
user = '******'
password = '******'

# Admin panel
browser.get(url_main)
time.sleep(load_time)

browser.find_element_by_xpath("//input[@id='username']").send_keys(user)
browser.find_element_by_xpath("//input[@id='login']").send_keys(password)
browser.find_element_by_xpath("//input[@class='form-button']").click()
time.sleep(load_time)

browser.find_element_by_xpath("//span[contains(text(), 'System')]").click()
browser.find_element_by_xpath("//span[contains(text(), 'Index Management')]").click()
time.sleep(load_time)

browser.find_element_by_xpath("//a[@onclick='return indexer_processes_grid_massactionJsObject.selectAll()']").click()
browser.find_element_by_xpath("//button[@onclick='indexer_processes_grid_massactionJsObject.apply()']").click()

wait(browser, 600).until(EC.text_to_be_present_in_element((By.ID, "indexer_processes_grid_massaction-count"), '0'))
items = browser.find_element_by_xpath("//strong[@id='indexer_processes_grid_massaction-count']").text

if items=='0':
	print "Reindexed successfully"
	pass
else:
	print "The reindexing operation took too long"
	pass

browser.quit()
Пример #41
0
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException
driver = webdriver.Remote('http://*****:*****@class="error" and @id="errpwderr"]'
    print 'Got timed out'
    try:
        elem = driver.find_element_by_xpath(lock)
        if elem.is_displayed():
            print 'locked '
            pwd = driver.find_element_by_id('p1210Password')
            pwd.send_keys('passw0rd')
            driver.find_element_by_id('p1210a005').click()
            wait(driver, 3).until(lambda _:'Network' in driver.title)
        else:
            elem = driver.find_element_by_xpath(dup)
            if elem.is_displayed():
                print 'we have dup'
Пример #42
0
    def _wait_number_changed(self, initial_number, get_new_number):
        def _number_changed(_driver):
            return get_new_number() != initial_number

        w = wait(self._driver, UI_MAX_IMPLICIT_TIMEOUT)
        w.until(_number_changed)
Пример #43
0
district = "Nagpur"
district_division = "Nagpur"

#URLs
search = "https://maharerait.mahaonline.gov.in/SearchList/Search"
search_list = "https://maharerait.mahaonline.gov.in/SearchList/SearchList"

# Start process
file = open(city, 'w+')
driver = webdriver.Chrome()
driver.get(search)
assert "Maharashtra Real Estate Regulatory Authority" in driver.title
promoter = driver.find_element_by_id("Promoter")
promoter.click()
try:
    advSearch = wait(driver, 2).until(EC.presence_of_element_located((By.ID,"btnAdvance")))
    advSearch.click()
    division = wait(driver, 2).until(EC.presence_of_element_located((By.ID,"Division")))
    select = Select(driver.find_element_by_id("Division"))
    select.select_by_visible_text(city)
    search = driver.find_element_by_id("btnSearch")
    search.click()
    gridView = wait(driver, 2).until(EC.presence_of_element_located((By.ID,"gridview")))
    pages = driver.find_element_by_xpath('//*[label[text()="of"]]').text
    totalPages = int(pages.split(" ")[-1])
    pdb.set_trace()
    print 'Total pages = ' + str(totalPages)
    project_list = list()
    for i in range(1, totalPages+1):
       projects = driver.find_elements_by_css_selector('td[data-name="Project"')
       for project in projects:
Пример #44
0
browser.get(url_main)
time.sleep(load_time)

browser.find_element_by_xpath("//input[@id='username']").send_keys(user)
browser.find_element_by_xpath("//input[@id='login']").send_keys(password)
browser.find_element_by_xpath("//input[@class='form-button']").click()
time.sleep(load_time)

browser.find_element_by_xpath("//span[contains(text(), 'System')]").click()
browser.find_element_by_xpath("//span[contains(text(), 'Cache Management')]").click()
time.sleep(load_time)

browser.find_element_by_xpath("//a[@onclick='return cache_grid_massactionJsObject.selectAll()']").click()
browser.find_element_by_xpath("//button[@onclick='cache_grid_massactionJsObject.apply()']").click()

wait(browser, 600).until(EC.text_to_be_present_in_element((By.ID, "cache_grid_massaction-count"), '0'))
items = browser.find_element_by_xpath("//strong[@id='cache_grid_massaction-count']").text
if items=='0':
	print "Magento's cache refreshed successfully"
	pass
else:
	print "The refreshing operation took too long"
	pass

browser.find_element_by_xpath("//button[@title='Flush Magento Cache']").click()
time.sleep(3)
print "Magento's cache flushed successfully"

browser.find_element_by_xpath("//button[@title='Flush Cache Storage']").click()
time.sleep(3)
print "Magento's storage cache flushed successfully"