Beispiel #1
0
def getLinks(topic, collection, driver):
	startPage = "http://www.cochranelibrary.com/home/topic-and-review-group-list.html?page=topic"
	# Clicking on given topic
	driver.get(startPage)
	# Loading the page
	driver.find_element_by_link_text(topic).click()
	# Waiting until page is loaded
	numberSelector = WebDriverWait(driver, 1).until(
        EC.presence_of_element_located((By.ID, "results_per_page_top"))
    )

	select = Select(numberSelector)
	# Loading 100 element on the page
	select.select_by_visible_text("100")
	time.sleep(3)

	# Gettin page number 
	pageNext = driver.find_element_by_class_name("results-block__pagination-list")
	listPage = pageNext.find_elements_by_tag_name("li")

	for i in range(len(listPage)-1):
		getLinksSinglePage(collection, driver)

		pageNext = driver.find_element_by_class_name("results-block__pagination-list")
		listPage = pageNext.find_elements_by_tag_name("li")

		# Click on next button
		listPage[-1].click()
		time.sleep(10)
 def search_for_class(self):
     self.driver.get(self.search_url)
     self.driver.switch_to.frame(self.driver.find_element_by_name('TargetContent'))
     
     select = Select(self.driver.find_element_by_id('CLASS_SRCH_WRK2_STRM$35$'))
     select.select_by_visible_text('2015 Spring')
     time.sleep(0.5)
     self.driver.find_element_by_id('SSR_CLSRCH_WRK_SUBJECT$0').send_keys(self.dept)
     time.sleep(0.5)
     self.driver.find_element_by_id('SSR_CLSRCH_WRK_SSR_OPEN_ONLY$3').click()
     time.sleep(0.5)
     self.driver.find_element_by_id('SSR_CLSRCH_WRK_CATALOG_NBR$1').send_keys(self.course_number)
     #really weird, but in phantomjs, the open class only button is deselected by default, uncomment next line if problems
     #self.driver.find_element_by_id('SSR_CLSRCH_WRK_SSR_OPEN_ONLY_LBL$3').click()
     self.driver.find_element_by_name('DERIVED_CLSRCH_SSR_EXPAND_COLLAPS$149$$IMG$1').click()
     self.driver.find_element_by_id('SSR_CLSRCH_WRK_CLASS_NBR$8').send_keys(self.class_number)
     self.driver.find_element_by_id('CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH').click()
     time.sleep(0.5)
     self.driver.save_screenshot('test.jpg')
     alt_text = self.driver.find_element_by_class_name('SSSIMAGECENTER').get_attribute('alt')
     if (alt_text == 'Open' or alt_text == 'Wait Listed'):
         robot = RegistryBot(self.username, self.password)
         robot.login()
         robot.submit_cart()
         time.sleep(1)
         robot.close()
Beispiel #3
0
    def test_store_cookie(self):
        driver = self.driver

        # get Your langauge droptown as instance of Select class
        select_language = Select(self.driver.find_element_by_id(
            "select-language"
        ))

        # check default selected option is English
        self.assertEqual(
            "ENGLISH",
            select_language.first_selected_option.text
        )

        # store cookie should be none
        store_cookie = driver.get_cookie("store")
        print("\nCookie is: ")
        print(store_cookie)
        self.assertEqual(None, store_cookie)

        # select option using select_y_visible text
        select_language.select_by_visible_text("French")

        # store cookie should be populated with selected country
        store_cookie = driver.get_cookie("store")['value']
        print("\nCookie is: ")
        print(store_cookie)
        self.assertEqual(
            "french",
            store_cookie
        )
Beispiel #4
0
def test_cannot_compute_zero_features(driver, project, dataset):
    driver.get('/')
    driver.refresh()
    proj_select = Select(driver.find_element_by_css_selector('[name=project]'))
    proj_select.select_by_value(str(project.id))

    driver.find_element_by_id('react-tabs-4').click()
    driver.find_element_by_partial_link_text('Compute New Features').click()
    driver.find_element_by_xpath("//li[contains(text(),'General')]").click()

    amplitude = driver.find_element_by_css_selector('[name=amplitude]')
    assert amplitude.get_attribute('value') == 'true'
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    time.sleep(0.1)
    assert amplitude.get_attribute('value') == 'false'

    driver.find_element_by_xpath("//li[contains(.,'Cadence')]").click()
    n_epochs = driver.find_element_by_css_selector('[name=n_epochs]')
    assert n_epochs.get_attribute('value') == 'true'
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    time.sleep(0.1)
    assert n_epochs.get_attribute('value') == 'false'

    driver.find_element_by_xpath("//li[contains(.,'Lomb-Scargle')]").click()
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    assert driver.find_element_by_css_selector(
        '[name=fold2P_slope_10percentile]').get_attribute('value') == 'false'

    featureset_name = driver.find_element_by_css_selector('[name=featuresetName]')
    featureset_name.send_keys(test_featureset_name)

    driver.find_element_by_class_name('btn-primary').click()

    driver.wait_for_xpath(
        "//div[contains(.,'At least one feature must be selected')]")
Beispiel #5
0
def makeselection():
	month = browser.find_element_by_xpath(".//a[contains(@onclick, 'jmpto1605')]")
	month.send_keys("\n")
	time.sleep(5) # delays for 5 seconds
	sectionDatesOfStay = browser.find_element_by_id('sectionDatesOfStay')
	containerDatesOfStay = sectionDatesOfStay.find_element_by_id('containerDatesOfStay')
	calCell = containerDatesOfStay.find_element_by_class_name('calCell')
	cal1 = calCell.find_element_by_id('cal1')
	calTable1605 = cal1.find_element_by_id('calTable1605')

	# Select May 28 as the arrival day
	date_28 = calTable1605.find_element_by_id('160528')
	date_28.send_keys("\n")
	time.sleep(5) # delays for 5 seconds

	# Select May 29 as the departure day
	date_29 = calTable1605.find_element_by_id('160529')
	date_29.send_keys("\n")
	time.sleep(5) # delays for 5 seconds

	# Select the adults number
	frmNumAdults = browser.find_element_by_id('frmNumAdults')
	adultNo = Select(frmNumAdults)
	adultNo.select_by_visible_text('2')

	# Check the room status
	time.sleep(5)
	suiteTypes = browser.find_element_by_id('suiteTypes')
	sendemail()
def walkProdCat():
    global driver, prevTrail
    try:
        # click "Drilldown"
        waitClickable('#ctl00_ctl00_ctl00_mainContent_localizedContent_bodyCenter_BasicSearchPanel_btnAdvancedSearch')\
            .click()

        zpath = ('#ctl00_ctl00_ctl00_mainContent_localizedContent_bodyCenter_'+
                 'adsPanel_lbProductCategory')
        curSel = Select(css(zpath))
        numProdCats = len(curSel.options)
        ulog('numProdCats=%d'%numProdCats)

        startIdx = getStartIdx()
        for idx in range(startIdx, numProdCats):
            curSel = Select(css(zpath))
            ulog("idx=%s"%idx)
            ulog('select "%s"'%curSel.options[idx].text)
            curSel.select_by_index(idx)
            prevTrail+=[idx]
            walkProdFam()
            prevTrail.pop()
    except Exception as ex:
        traceback.print_exc(); ipdb.set_trace()
        driver.save_screenshot('netgear_exc.png')
Beispiel #7
0
def getHtml(word,driver):

    driver.get('http://www.shufazidian.com')

    elem = driver.find_element_by_name('wd')

    select = Select(driver.find_element_by_name('sort'))
    select.select_by_value('9')
    # print('1, ', ctime())
    elem.send_keys(word)
    # wait = WebDriverWait(driver,5)
    elem.send_keys(Keys.RETURN)
    # driver.implicitly_wait(5)
    # try:
    #     element = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'.mbpho')))
    #     print('3, ',ctime())
    # except Exception,e:
    #     print(e)
    # print('4, ', ctime())

    delay = 7 # seconds
    try:
        WebDriverWait(driver, delay).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'.mbpho')))
    except TimeoutException:
        # print >>f , "TimeoutException Loading took too much time!"
        pass
    time.sleep(5)

    return driver.page_source
  def test_04_dep_bar_content(self):
    chart_titles = ['VistA Packages Dependencies Chart','VistAPackageStatistics']
    dep_chart_legend = ['depends','dependents']
    dep_chart_top_entries = ['Kernel','Order Entry Results Reporting','Accounts Receivable']
    global driver

    # Ensure that the data and labels of chart are not empty
    chart_container = driver.find_elements_by_class_name("highcharts-series")
    for type in chart_container:
      bar_array = type.find_elements_by_tag_name("rect")
      self.assertTrue(len(bar_array) > 0)

    chart_container = driver.find_elements_by_class_name("highcharts-data-labels")
    for type in chart_container:
      bar_array = type.find_elements_by_tag_name("text")
      self.assertTrue(len(bar_array) > 0)


    # Read title of graph
    bar_chart = driver.find_element_by_id("bar-chart")
    title_element = bar_chart.find_element_by_class_name("highcharts-title")
    self.assertTrue(title_element.text in chart_titles)
    # Ensure that legends have proper information
    chart_legend = bar_chart.find_element_by_class_name("highcharts-legend")
    legend_array = chart_legend.find_elements_by_tag_name("text")
    for item in legend_array:
       self.assertTrue(item.get_attribute("innerHTML") in dep_chart_legend)

    # Check each of the "Sort By" selections to ensure that the first element is found in top_entries array
    dep_pulldown = bar_chart.find_element_by_id("list-dep")
    pulldown_options = Select(dep_pulldown)
    for option in pulldown_options.options:
      pulldown_options.select_by_visible_text(option.text)
      self.assertTrue( driver.find_element_by_xpath("//*[@id='highcharts-0']/div/span[1]").text in dep_chart_top_entries)
      time.sleep(5)
def walkProd():
    global driver, prevTrail
    try:
        # click overlay advertisement popup left button "No Thanks"
        try:
            driver.find_element_by_css_selector("a.btn.close.fl-left").\
                    click()
        except (NoSuchElementException):
            pass

        zpath = ('#ctl00_ctl00_ctl00_mainContent_localizedContent_bodyCenter'+
                 '_adsPanel_lbProduct')
        waitTextChanged(zpath)
        curSel = Select(css(zpath))
        numProds = len(curSel.options)
        ulog("numProds=%d"%numProds)

        startIdx = getStartIdx()
        for idx in range(startIdx, numProds):
            curSel = Select(css(zpath))
            ulog("idx=%s"%idx)
            ulog('select "%s"'%curSel.options[idx].text)
            curSel.select_by_index(idx)
            prevTrail+=[idx]
            while True:
                ret = walkFile()
                if ret != TRY_AGAIN:
                    break
            if ret== PROC_GIVE_UP:
                ulog('"%s" is GIVE UP'% curSel.options[idx].text)
            prevTrail.pop()
        return PROC_OK
    except Exception as ex:
        traceback.print_exc(); ipdb.set_trace()
        driver.save_screenshot('netgear_exc.png')
Beispiel #10
0
    def persistent_filter_test(self):
        pla = platform_get()
        # go to test page, tab Fragility
        pla.get('/vulnerability/list?type_of_assessment=1')

        # find LLRS dropdown filter menu
        sel_tag = pla.xpath_finduniq(
            "//form[@name='filter']//select[@id='id_llrs']")
        sel = Select(sel_tag)
        sel.select_by_value("LWAL")

        # find filter button and click it
        filter = pla.xpath_finduniq(
            "//form[@name='filter']//button[@type='submit' and"
            " @value='Filter']")
        filter.click()

        # move to tab vulnerability
        pla.get('/vulnerability/list?type_of_assessment=2')
        pla.waituntil_js(10, ("try { return (window.gem_app_initialized"
                              " == true); } catch (exc) { return false; }"))


        # find again LLRS dropdown filter menu
        sel_tag = pla.xpath_finduniq(
            "//form[@name='filter']//select[@id='id_llrs']")
        sel = Select(sel_tag)

        # retrieve the selected item (that must be equal
        # to the previous selected)
        selected_item = sel.all_selected_options

        # check if the value is the same selected in the previous page
        self.assertEqual(selected_item[0].get_attribute('value'), 'LWAL')
    def test_new_duplicates_project_name(self):
        """
        Should not be able to create a new project whose name is the same
        as an existing project
       """

        project_name = "dupproject"

        Project.objects.create_project(name=project_name,
                                       release=self.release)

        url = reverse('newproject')
        self.get(url)

        self.enter_text('#new-project-name', project_name)

        select = Select(self.find('#projectversion'))
        select.select_by_value(str(self.release.pk))

        element = self.wait_until_visible('#hint-error-project-name')

        self.assertTrue(("Project names must be unique" in element.text),
                        "Did not find unique project name error message")

        # Try and click it anyway, if it submits we'll have a new project in
        # the db and assert then
        self.click("#create-project-button")

        self.assertTrue(
            (Project.objects.filter(name=project_name).count() == 1),
            "New project not found in database")
Beispiel #12
0
def boostme(driver,NotAmped,amptype,doubledipchoice):

	if amptype=='DD':

		for k,v in NotAmped.iteritems():

			v.click()
			time.sleep(SLEEP_SECONDS)

			sele=Select(driver.find_element_by_xpath("//*[@id='secondPool']/div/div/div[2]/form/div/select"))
			dropdown_options = sele.options

			
			for available in range(0,len(dropdown_options)):
				current_option=dropdown_options[available].text

				if doubledipchoice==current_option:
					sele.select_by_visible_text(current_option)
					time.sleep(SLEEP_SECONDS)
					break
			SecondPoolDiv=driver.find_element_by_id("secondPool")

			SecondPoolDiv.find_element_by_xpath(".//button[contains(text(), 'Add Pool')]").click()

			time.sleep(SLEEP_SECONDS)
	
	elif amptype=='Boost':
		
		for k,v in NotAmped.iteritems():
			v.click()
			time.sleep(5)
Beispiel #13
0
 def submit_form(self, form, data, clear=True, submit=True, wait=True):
     for k, v in data.items():
         input_field = form.find_element_by_name(k)
         if input_field.tag_name in ('input', 'textarea'):
             field_type = input_field.get_attribute('type')
             if field_type == 'radio':
                 radio_button = form.find_element_by_css_selector(
                     "input[type=radio][name={}][value='{}']".format(
                         k, v
                     )
                 )
                 radio_button.click()
             elif field_type == 'checkbox':
                 checkbox_button = form.find_element_by_css_selector(
                     'input[type=checkbox][name={}]'.format(k)
                 )
                 if v and not checkbox_button.is_selected():
                     checkbox_button.click()
                 elif not v and checkbox_button.is_selected():
                     checkbox_button.click()
             elif clear and input_field.get_attribute('value'):
                 input_field.clear()
             input_field.send_keys(v)
         elif input_field.tag_name == 'select':
             select_field = Select(input_field)
             select_field.select_by_value(v)
     if submit:
         submit_btn = form.find_element_by_xpath(
             './/button[@type="submit"]')
         submit_btn.click()
     if wait:
         self.wait_for_page_load()
Beispiel #14
0
 def select_state(self, country):
     select = Select(self.driver.find_element(*ShippingPageLocators.STATE_DROPDOWN))
     if country==None:
         random = randint(0,3)
         select.select_by_index(state_number)
     else:
         select.select_by_visible_text(country)
Beispiel #15
0
 def select_state(self, state):
     select = Select(self.driver.find_element(*ShippingPageLocators.STATE_DROPDOWN))
     if state==None:
         state_number = randint(0,49)
         select.select_by_index(state_number)
     else:
         select.select_by_visible_text(state)
Beispiel #16
0
    def _open_all_the_tables():
        refresh_window(world)
        pagers = get_elements(world.browser, class_attr="gridview", tag_name="table")
        pagers = filter(lambda x : x.is_displayed(), pagers)
        for pager in pagers:
            elem = get_element(pager, class_attr="pager_info", tag_name="span")

            m = re.match('^\d+ - (?P<from>\d+) of (?P<to>\d+)$', elem.text.strip())
            do_it = False

            if m is None:
                do_it = True
            else:
                gp = m.groupdict()
                do_it = gp['from'] != gp['to']

            if do_it:
                elem.click()

                # we cannot select an unlimited number of items. So we stick to 500
                #  even if we know that the row we are looking for is in the next page... (comes from US-1207)
                element = get_element(pager, tag_name="select", attrs=dict(action="filter"))
                select = Select(element)
                select.select_by_visible_text("500")

                wait_until_not_loading(world.browser, wait="I cannot load the whole table")
Beispiel #17
0
    def test_generate_by_whiteboard(self):
        b = self.browser
        b.get(get_server_base() + 'matrix/')
        Select(b.find_element_by_name('whiteboard'))\
            .select_by_visible_text(self.job_whiteboard)
        b.find_element_by_xpath('//button[text()="Generate"]').click()
        b.find_element_by_xpath('//table[@id="matrix_datagrid"]'
                '//td[normalize-space(string(.))="Pass: 1"]')
        with session.begin():
            new_job = data_setup.create_completed_job(
                whiteboard=self.job_whiteboard, result=TaskResult.pass_,
                recipe_whiteboard=self.recipe_whiteboard)
        b.find_element_by_xpath('//button[text()="Generate"]').click()
        b.find_element_by_xpath('//table[@id="matrix_datagrid"]'
                '//td[normalize-space(string(.))="Pass: 2"]')

        #Try with multiple whiteboards
        with session.begin():
            another_new_job = data_setup.create_completed_job(
                whiteboard=self.job_whiteboard_2, result=TaskResult.pass_,
                recipe_whiteboard=self.recipe_whiteboard)
        b.get(get_server_base() + 'matrix/')
        whiteboard = Select(b.find_element_by_name('whiteboard'))
        whiteboard.select_by_visible_text(self.job_whiteboard)
        whiteboard.select_by_visible_text(self.job_whiteboard_2)
        b.find_element_by_xpath('//button[text()="Generate"]').click()
        b.find_element_by_xpath('//table[@id="matrix_datagrid"]'
                '//td[normalize-space(string(.))="Pass: 3"]')
def marketWalker():
    global driver,prevTrail
    try:
        showEol=waitVisible('#showEndLife')
        if not showEol.is_selected():
            showEol.click()
        selMkt= Select(waitVisible('.product-cat-box select:nth-child(1)'))
        startIdx=getStartIdx()
        numMkts = len(selMkt.options)
        curSel = selMkt.all_selected_options[0].text
        ulog('current Selected="%s"'%curSel)
        for idx in range(startIdx, numMkts):
            selMkt.select_by_index(idx)
            nextSel=selMkt.options[idx].text
            ulog('gonna select "%s"'%nextSel)
            btn = waitVisible('button.round-button.go')
            with UntilTextChanged('.content-box',9,0.4):
                btn.click()
            prevTrail+=[idx]
            modelWalker()
            prevTrail.pop()
            showEol=waitVisible('#showEndLife')
            if not showEol.is_selected():
                showEol.click()
            selMkt= Select(waitVisible('.product-cat-box select:nth-child(1)'))
    except Exception as ex:
        ipdb.set_trace()
        traceback.print_exc()
        driver.save_screenshot(getScriptName()+'_'+getFuncName()+'_exc.png')
def login():
    #driver = webdriver.Firefox()
    link = "http://goarticles.com/members/"
    driver = firebug_proxy2.main(link)
    #driver.get(link)
    elem = driver.find_element_by_name("email")
    elem.send_keys("*****@*****.**")
    elem = driver.find_element_by_name("password")
    elem.send_keys("xxxxxxx")
    elem.send_keys(Keys.RETURN)
    #dir(driver)
    elem = driver.find_element_by_id("add_new")
    elem.send_keys(Keys.RETURN)
    select = Select(driver.find_element_by_name('category_id'))
    
    select.select_by_index(2)
    #select = Select(driver.find_element_by_name('sub_category_id'))
    #select.select_by_index(1)
    elem = driver.find_element_by_name("title")
    title  = "Different Ways You Can Define Yourself  "
    elem.send_keys(title)
    f = open("f1.html")
    body = f.read()
    body = unicode(body, errors='ignore')
    f.close()
    elem = driver.find_element_by_name("body")
    elem.send_keys(body)
    bio =" name  Kaya, just learing how to write a article"
    elem = driver.find_element_by_name("resource")
    elem.send_keys(bio)
    elem = driver.find_element_by_name("submit").click()
    #elem.submit() 
    time.sleep(5)
    driver.close()
    def credetials_to_edit_school(self,
                                  driver,
                                  school_name,
                                  address,
                                  xpath_of_school_to_edit,
                                  xpath_of_director):
        """ Function to automate proccess of inserting the credentials """

        driver.find_element_by_xpath(xpath_of_school_to_edit).click()
        input_name_area = driver.find_element_by_xpath(
            self.xpaths['inputSchoolName'])
        input_address_area = driver.find_element_by_xpath(
            self.xpaths['inputSchoolAddress'])
        input_name_area.clear()
        input_name_area.send_keys(school_name)
        input_address_area.clear()
        input_address_area.send_keys(address)

        driver.find_element_by_xpath(
            xpath_of_director).click()

        select = Select(driver.find_element_by_xpath(xpath_of_director))

        select.select_by_value('12')
        driver.find_element_by_xpath(
            self.xpaths['confirmAddEditButton']).click()
 def fill_address(self):
     try:
         wait = self.wait
         contact_page = self.contact_page
         wait.until(lambda d: contact_page.another_address_button().is_displayed(), message="brak buttona another adress")
         contact_page.another_address_button().click()
         wait.until(lambda d: len(contact_page.address_forms()) > 1)
         for i in range(2):
             contact = self.contact[i]
             wait.until(lambda d: contact_page.street_inputs()[i].is_displayed(), message="pole ulica jest niewidoczne")
             contact_page.street_inputs()[i].send_keys(contact['street'])
             wait.until(lambda d: contact_page.region_inputs()[i].is_displayed(), message="pole wojewodztwo jest niewidoczne")
             contact_page.region_inputs()[i].send_keys(contact['region'])
             wait.until(lambda d: contact_page.postcode_inputs()[i].is_displayed(), message="pole kod pocztowy jest niewidoczne")
             contact_page.postcode_inputs()[i].send_keys(contact['postcode'])
             wait.until(lambda d: contact_page.city_inputs()[i].is_displayed(), message="pole miasto jest niewidoczne")
             contact_page.city_inputs()[i].send_keys(contact['city'])
             wait.until(lambda d: contact_page.country_inputs()[i].is_displayed(), message="pole kraj jest niewidoczne")
             contact_page.country_inputs()[i].send_keys(contact['country'])
             wait.until(lambda d: contact_page.address_dropdown_menues()[i].is_displayed(), 
                 message="menu kategorii adresu nie zostalo wyswietlone")
             select = Select(contact_page.address_dropdown_menues()[i])
             select.select_by_value(contact['type'])
     except Exception:
         pytest.allure.attach(sys._getframe().f_code.co_name, self.driver.get_screenshot_as_png(), type=AttachmentType.PNG)
         raise
 def select_current_climate_layers(self, resolution, string):
     # select the correct resolution filter
     select = Select(self.driver.find_element_by_name("form.widgets.resolution:list"))
     select.select_by_visible_text(resolution)
     # Yes, there is a type here, but that's how it is on the backend
     path_string = "(//tr[@data-friendlyname='collapbsable_climatelayer_" + string + "'])"
     self.driver.find_element_by_xpath(path_string).click()
Beispiel #23
0
    def _test_fxa_signup(self):
        '''FullFlow1:create, signout - %s %s %s''' % \
        (self.os, self.br, self.version)

        self.driver.get(FXA_SIGNUP)
        time.sleep(2)
        assert 'Create' in self.driver.title

        username = self.driver.find_element_by_css_selector(input_email)
        username.send_keys(self.fxa_new_user)
        time.sleep(2)
        pw = self.driver.find_element_by_css_selector(input_password)
        pw.send_keys(fxa_password)

        selectBox = Select(self.driver.find_element_by_id(coppa_locator))
        time.sleep(2)
        selectBox.select_by_visible_text("1991")

        self.driver.find_element_by_id(btn_submit).click()

        self.wait_page_load(FXA_SIGNUP)
        assert 'Confirm your account' in self.driver.title

        # verify restmail user
        time.sleep(4)
        restmail_link = getRestmailLink(self.fxa_new_user)
        self.driver.get(restmail_link)
        time.sleep(2)
        assert 'verified' in self.driver.title
    def bulkCreate(self):
        self.log.write("namepefix id" +self.guestNamePefix)
        self.browser.find_element_by_xpath("//*[@id='guestName']").send_keys(self.guestNamePefix)
        self.browser.find_element_by_xpath("//*[@id='userProfile']").clear()
        self.log.write("guestnumber is"+self.guestNumber)
        self.browser.find_element_by_xpath("//*[@id='userProfile']").send_keys(self.guestNumber)
        self.log.write("select guest type,guest type is"+self.guestType)
        select = Select(self.browser.find_element_by_xpath("//*[@name='authType']")) 
        select.select_by_visible_text(self.guestType)
        time.sleep(2)
#         //*[@id="J-create"]
        self.log.write("click 'create'")
        self.browser.find_element_by_xpath("//a[@id='J-create']").click()
        time.sleep(2)
        self.guestinfo.append("Wi-Fi Network:")
        self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr/td[2]/p").text)
        self.guestinfo.append("Prefix for Guest Names:")
        self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr[2]/td[2]/p").text)
        self.guestinfo.append("Number of Guests:")
        self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr[3]/td[2]/p").text)
        self.guestinfo.append("Access Duration:")
        self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr[4]/td[2]/p").text)
        self.browser.find_element_by_xpath("//*[@id='deliver-name']").send_keys(self.email)
        self.log.write("click 'comfirm'")
        self.browser.find_element_by_xpath("/html/body/div/div[2]/div[2]/div[2]/div/form/fieldset[2]/table/tbody/tr[3]/td[2]/p/a").click()
        time.sleep(2)
    def createGuest(self):
#         self.gotoCreateGuest(self)
#         self.browser.find_element_by_xpath("/html/body/div/div[2]/div[2]/div/div[2]/div/div/p[2]/a").click()
        time.sleep(2)
        self.log.write("guetname is "+self.guestName)
        self.browser.find_element_by_xpath("//*[@id='guestName']").send_keys(self.guestName)
        self.log.write("organization is" +self.organization)
        self.browser.find_element_by_xpath("//*[@id='organization']").send_keys(self.organization)
        self.log.write("purpose is"+self.purposeOfVisit)
        self.browser.find_element_by_xpath("//*[@id='visitPurpose']").send_keys(self.purposeOfVisit)
        self.log.write("email is "+self.email)
        self.browser.find_element_by_xpath("//*[@id='email']").send_keys(self.email)
        self.log.write("phone is" +self.phone)
        self.browser.find_element_by_xpath("//*[@id='phoneNumber']").send_keys(self.phone)
        self.log.write("the type of logname is"+self.loginName)
        self.browser.find_element_by_xpath("//input[@value='"+self.loginName+"']").click()
#         logname:email,phone,name
        self.log.write("select guesttype" +self.guestType)
        select = Select(self.browser.find_element_by_xpath("//*[@id='J-guest-type']")) 
        select.select_by_visible_text(self.guestType)
        self.log.write("click 'create'")
        self.browser.find_element_by_xpath("//*[@id='J-next']").click()
#         guestSsid=self.browser.find_elenment_by_xpath("//form[@id='new-gt-form']/fieldset[3]/table/tbody/tr[2]/td[2]/p[2]/span").text
#         self.browser.find_element_by_xpath("//form[@id='new-gt-form']/fieldset[3]/table/tbody/tr[4]/td[2]/p/a").click()
        
#         self.guestloginName=self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset/table/tbody/tr[2]/td[2]/p").text
#         self.guestpasswd=self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset/table/tbody/tr[3]/td[2]/p").text
#         self.accessTime=self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset/table/tbody/tr[4]/td[2]/p").text
#         self.sendEmail=self.browser.find_element_by_path("//*[@id='deliver-name']").text  
        time.sleep(2)
        self.log.write("click 'confirm'")
        self.browser.find_element_by_xpath("/html/body/div/div[2]/div[2]/div[2]/div/form/fieldset[2]/table/tbody/tr[3]/td[2]/p/a").click()
                                                 
#         self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset[2]/table/tbody/tr[3]/td[2]/p/a").click()
        time.sleep(2)
def create_csv(year,month):
	path = os.getcwd()+os.sep+"temp"
	profile = webdriver.FirefoxProfile()
	profile.set_preference('browser.download.folderList', 2) # custom location
	profile.set_preference('browser.download.manager.showWhenStarting', False)
	profile.set_preference('browser.download.dir', path)
	profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')
	driver = webdriver.Firefox(profile)
	try:
		driver.get("https://www.ura.gov.sg/realEstateIIWeb/price/search.action")
		driver.implicitly_wait(5)
		select_year = Select(driver.find_element_by_name('yearSelect'))
		onchange_null  = "document.getElementById('yearSelect').onchange='';document.getElementById('monthSelect').onchange='';"
		clear_month = "$('#monthSelect').empty();"
		append_month = "$('#monthSelect').append(\"<option selected='selected' value="+str(month)+">"+str(month)+"</option>\");"  
		driver.execute_script(clear_month)
		driver.execute_script(onchange_null)
		driver.execute_script(append_month)
		select_year.select_by_visible_text(year)
		driver.execute_script("submitViewAll()")
		driver.implicitly_wait(5)
		driver.get("https://www.ura.gov.sg/realEstateIIWeb/price/submitExcelResults.action")
		print(year,month)
		driver.close()
	except:
		print("Logging missed values")
		print(year,month)
		print(sys.exc_info())
		log.append([year,month])
		driver.implicitly_wait(10)
Beispiel #27
0
    def select(self, selector, value):
        from selenium.webdriver.support.ui import Select

        elem = self.selenium.find_element_by_css_selector(selector)
        select = Select(elem)

        select.select_by_visible_text(value)
Beispiel #28
0
def test_volvox():
    format_volvox()
    browser = webdriver.Firefox() # Get local session of firefox
    browser.get("file://%s/index.html?data=sample_data/json/volvox" % os.getcwd() ) # Load page

    # select "ctgA from the dropdown
    refseq_selector = Select(browser.find_element_by_id('chrom'))
    refseq_selector.select_by_value('ctgA')

    # check a good browser title
    assert "ctgA" in browser.title, "browser title is actually %s" % browser.title

    tabs = browser.find_elements_by_xpath( '//div[@class="browsingTab"]' )
    for t in tabs:
        t.click()
        time.sleep(1)
        t.click()
        time.sleep(0.5)

    assert_no_js_errors(browser)

    # do a test where we search for a certain gene using the search box
    search_f15(browser)

    assert_no_js_errors(browser)

    # test scrolling, make sure we get no js errors
    scroll(browser)

    # test dragging in and displaying the wiggle track
    wiggle(browser)

    browser.close()
    pass;
Beispiel #29
0
def test_check_uncheck_features(driver, project, dataset):
    driver.get('/')
    driver.refresh()
    proj_select = Select(driver.find_element_by_css_selector('[name=project]'))
    proj_select.select_by_value(str(project.id))

    driver.find_element_by_id('react-tabs-4').click()
    driver.find_element_by_partial_link_text('Compute New Features').click()
    driver.find_element_by_xpath("//li[contains(text(),'General')]").click()

    amplitude = driver.find_element_by_css_selector('[name=amplitude]')
    assert amplitude.get_attribute('value') == 'true'
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    time.sleep(0.3)
    assert amplitude.get_attribute('value') == 'false'
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    time.sleep(0.1)
    assert amplitude.get_attribute('value') == 'true'

    driver.find_element_by_xpath("//li[contains(.,'Cadence')]").click()
    n_epochs = driver.find_element_by_css_selector('[name=n_epochs]')
    assert n_epochs.get_attribute('value') == 'true'
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    time.sleep(0.1)
    assert n_epochs.get_attribute('value') == 'false'

    driver.find_element_by_xpath("//li[contains(.,'Lomb-Scargle')]").click()
    driver.find_element_by_partial_link_text('Check/Uncheck All').click()
    assert driver.find_element_by_css_selector(
        '[name=fold2P_slope_10percentile]').get_attribute('value') == 'false'
Beispiel #30
0
 def select_term(self, term):
     d = self.driver
     d.get('https://loris.wlu.ca/ssb_prod/bwskflib.P_SelDefTerm')
     dropdown = Select(d.find_element_by_id('term_id'))
     dropdown.select_by_value(term)
     d.find_elements_by_css_selector('form')[1].submit()
     self.term_selected = True
Beispiel #31
0
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time

driver = webdriver.Chrome();
driver.get("http://testwisely.com/demo");
time.sleep(1);
driver.set_window_size(1024,768);
driver.set_window_position(100,100);
driver.implicitly_wait(10);
driver.find_element_by_link_text("Customer Interview").click();
driver.find_elements_by_link_text("Show Answer")[1].click();

driver.get("http://testwisely.com/demo/netbank");
assert(driver.find_element_by_id("transfer_btn").is_displayed());
time.sleep(10);

driver.get("http://testwisely.com/demo/survey");
select_box = Select(driver.find_element_by_name("role")).select_by_visible_text("Manager");
time.sleep(10);

driver.quit();





def drop_down_selection(element_id, selection):
    variable = browser.find_element_by_id(element_id)
    var = Select(variable)
    var.select_by_visible_text(selection)
Beispiel #33
0
 def drop_down_menu(self, element, text):
     select = Select(self.driver.find_element_by_xpath(element))
     select.select_by_visible_text(text)
 def set_dropoff_time(self, value):
     select_element = self.get_descendant_elements(
         self.__DROPOFF_TIME_SELECT)[1]
     select = Select(select_element)
     select.select_by_value(value)
 def set_pickup_time(self, value):
     select_element = self.get_descendant_elements(
         self.__PICKUP_TIME_SELECT)[0]
     select = Select(select_element)
     select.select_by_value(value)
def scraper(url,
            table_class,
            table_id,
            start_date,
            response,
            table_filter=False):

    from selenium import webdriver
    from selenium.webdriver.support.ui import Select
    import time
    from bs4 import BeautifulSoup
    import pandas as pd

    chrome_driver = r"C:\Users\kbhandari\OneDrive - Epsilon\Desktop\Stocks\chromedriver.exe"
    driver = webdriver.Chrome(chrome_driver)
    driver.set_page_load_timeout(45)

    base_url = "https://in.investing.com"
    driver.get(url)
    time.sleep(3)

    #Filter
    if table_filter == False:
        pass
    else:
        mySelect = Select(driver.find_element_by_id("stocksFilter"))
        mySelect.select_by_visible_text(table_filter)
        time.sleep(3)

    #Getting names and URLs from table
    html = driver.page_source
    soup = BeautifulSoup(html, 'html.parser')
    table = soup.find('table', {'class': table_class, 'id': table_id})
    element = list()
    for a in table.findAll('a', href=True):
        if a.get_text().upper() != response.upper():
            element.append((a.get_text(), base_url + a['href']))

    #Getting historic data for each element
    n = len(element)
    i = 1
    first_time = True
    for info in element:
        print(info[0], ": ", i, "out of", n)
        i += 1
        driver.get(info[1])
        time.sleep(2)
        nav_btn = driver.find_element_by_link_text("Add to Portfolio")
        time.sleep(2)
        driver.execute_script("arguments[0].scrollIntoView();", nav_btn)
        time.sleep(2)
        driver.find_element_by_link_text("Historical Data").click()
        time.sleep(2)
        driver.find_element_by_id("widgetFieldDateRange").click()
        time.sleep(2)
        driver.find_element_by_id("startDate").clear()
        time.sleep(2)
        driver.find_element_by_id("startDate").send_keys(start_date)
        time.sleep(2)
        driver.find_element_by_id("applyBtn").click()
        time.sleep(5)
        html = driver.page_source

        soup = BeautifulSoup(html, 'html.parser')
        table = soup.find('table', {'class': 'genTbl closedTbl historicalTbl'})

        #Table Headers
        table_head = table.find('thead')
        header = []
        for th in table_head.findAll('th'):
            key = th.get_text()
            if key != 'Date':
                key = info[0] + '_' + key
            key = key.replace('%', '').replace('/',
                                               '_').replace('.', '').replace(
                                                   ' ', '').replace('+', '')
            header.append(key)

        #Table Rows
        l = []
        for tr in table.findAll('tr'):
            td = tr.find_all('td')
            if len(td) > 0:
                row = [tr.text for tr in td]
                l.append(row)

        #Check for empty table
        if l[0][0] == 'No results found':
            pass
        else:
            if first_time:
                universe = pd.DataFrame(l, columns=header)
                universe = universe[[
                    col for col in universe.columns
                    if 'Date' in col or 'Price' in col or 'Vol' in col
                ]]
                first_time = False
            else:
                df = pd.DataFrame(l, columns=header)
                df = df[[
                    col for col in df.columns
                    if 'Date' in col or 'Price' in col or 'Vol' in col
                ]]
                universe = pd.merge(universe, df, on='Date')

    driver.close()
    driver.quit()
    return universe
def get_stock_data(stock_name, out_file_name, from_day, from_month, from_year,
                   to_day, to_month, to_year):

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.support.ui import Select
    from selenium.webdriver.support.ui import WebDriverWait as wait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    import time
    options = Options()
    options.add_experimental_option(
        "prefs", {
            "download.default_directory":
            r"C:\Users\kbhandari\OneDrive - Epsilon\Desktop\Stocks",
            "download.prompt_for_download": False,
            "download.directory_upgrade": True,
            "safebrowsing.enabled": True
        })

    # url = "https://www.bseindia.com/markets/equity/EQReports/StockPrcHistori.aspx?expandable=7&scripcode=532648&flag=sp&Submit=G"
    url = "https://www.bseindia.com/markets/equity/EQReports/StockPrcHistori.aspx?scripcode=500247"
    chrome_driver = r"C:\Users\kbhandari\OneDrive - Epsilon\Desktop\Stocks\chromedriver.exe"
    driver = webdriver.Chrome(chrome_driver, options=options)
    driver.set_page_load_timeout(45)
    driver.get(url)
    time.sleep(1)

    driver.find_element_by_id("ContentPlaceHolder1_smartSearch").clear()
    time.sleep(1)
    driver.find_element_by_id("ContentPlaceHolder1_smartSearch").send_keys(
        stock_name)
    time.sleep(2)
    time.sleep(1)
    drop_down = driver.find_elements_by_css_selector("li.quotemenu a")
    for values in drop_down:
        values.click()
        break
    #driver.find_element_by_id("ContentPlaceHolder1_smartSearch").click()
    time.sleep(1)
    driver.find_element_by_id("ContentPlaceHolder1_txtFromDate").click()
    time.sleep(1)
    if int(from_year) < 2009:
        mySelect = Select(
            driver.find_element_by_class_name("ui-datepicker-year"))
        time.sleep(1)
        mySelect.select_by_visible_text("2009")
        time.sleep(1)
    mySelect = Select(driver.find_element_by_class_name("ui-datepicker-year"))
    time.sleep(1)
    mySelect.select_by_visible_text(from_year)
    mySelect = Select(driver.find_element_by_class_name("ui-datepicker-month"))
    mySelect.select_by_visible_text(from_month)
    wait(driver, 10).until(
        EC.visibility_of_element_located(
            (By.XPATH,
             "//td[@data-handler='selectDay']/a[text()='{}']".format(from_day)
             ))).click()
    time.sleep(1)

    driver.find_element_by_id("ContentPlaceHolder1_txtToDate").click()
    time.sleep(1)
    if int(to_year) < 2009:
        mySelect = Select(
            driver.find_element_by_class_name("ui-datepicker-year"))
        time.sleep(1)
        mySelect.select_by_visible_text("2009")
        time.sleep(1)
    mySelect = Select(driver.find_element_by_class_name("ui-datepicker-year"))
    time.sleep(1)
    mySelect.select_by_visible_text(to_year)
    time.sleep(1)
    mySelect = Select(driver.find_element_by_class_name("ui-datepicker-month"))
    mySelect.select_by_visible_text(to_month)
    wait(driver, 10).until(
        EC.visibility_of_element_located(
            (By.XPATH,
             "//td[@data-handler='selectDay']/a[text()='{}']".format(to_day)
             ))).click()
    time.sleep(1)

    driver.find_element_by_id('ContentPlaceHolder1_btnSubmit').click()
    time.sleep(2)
    driver.find_element_by_id('ContentPlaceHolder1_btnDownload').click()
    time.sleep(2)
    driver.quit()

    import os
    import shutil

    path = r"C:\Users\kbhandari\OneDrive - Epsilon\Desktop\Stocks"
    os.chdir(path)
    filename = max([f for f in os.listdir(path)], key=os.path.getctime)
    shutil.move(os.path.join(path, filename), out_file_name)
    return True
    def show_funds(self):
        time.sleep(5)
        self.driver.find_element_by_xpath(
            self.locators["Fund_input_box"]).send_keys(
                "Sun Life Granite Balanced Class")
        select_asset = Select(
            self.driver.find_element_by_xpath(
                self.locators["Asset_class_dropdown"]))
        # select by visible text
        time.sleep(2)
        select_asset.select_by_visible_text('Portfolio Solutions')

        select_series = Select(
            self.driver.find_element_by_xpath(
                self.locators["Series_dropdown"]))
        time.sleep(1)
        select_series.select_by_visible_text('A')
        select_currency = Select(
            self.driver.find_element_by_xpath(
                self.locators["Currency_dropdown"]))
        time.sleep(1)
        select_currency.select_by_visible_text('CAD')
        self.driver.find_element_by_xpath(
            self.locators["Show_funds_button"]).click()
        time.sleep(1)
        self.get_all_data_from_a_table(self.locators["table1"])
def select_from_drop_down(driver, name, value):
    assert "Neo New card maker" in driver.title  # First make sure we're still on the same page.
    drop_down = Select(
        driver.find_element(By.XPATH,
                            '//label[text()=\"' + name + '\"]/select[1]'))
    drop_down.select_by_value(value)
from selenium.webdriver.support.ui import Select


def calc(x):
    return str(math.log(abs(12 * math.sin(int(x)))))


try:
    browser = webdriver.Chrome()
    browser.get('http://suninjuly.github.io/execute_script.html')
    #считаем Х
    x_element = browser.find_element_by_css_selector('#input_value')
    x = x_element.text
    #считаем формулу
    calc(x)
    #скроллим
    button = browser.find_element_by_css_selector(".btn.btn-primary")
    browser.execute_script("return arguments[0].scrollIntoView(true);", button)

    button.click()

    select = Select(browser.find_element_by_css_selector('#dropdown'))
    select.select_by_value(str(sum))

    button = browser.find_element_by_css_selector('.btn.btn-default').click()

finally:
    # ожидание чтобы визуально оценить результаты прохождения скрипта
    time.sleep(10)
    # закрываем браузер после всех манипуляций
    browser.quit()
Beispiel #41
0
    print("Element not foud")

#driver.find_element_by_css_selector("div.account-login-wrapper #redhat-account-login-link").click()
driver.find_element_by_id("username").send_keys("bugbeckham")
driver.find_element_by_id("password").send_keys("as12AS!@")
driver.find_element_by_id("_eventId_submit").click()
#assert (driver.find_element_by_css_selector(span:contains[Invalid username or password.])).text
#element = driver.find_element_by_css_selector("span.kc-feedback-text").get_attribute("innerText")
#assert "Invalid username or password." in element

driver.find_element_by_id("customerPortalLink").click()

time.sleep(5)

select = Select(
    driver.find_element_by_css_selector(
        "a.btn.product-btn.style-scope.ts-chosen-selector"))
print(select.options)

dropdownelement = driver.find_element_by_css_selector(
    "a.btn.product-btn.style-scope.ts-chosen-selector")

for option in dropdownelement.find_elements_by_css_selector('option'):
    if option.text == 'Ansible Tower by Red Hat':
        option.click()

# print('outside try finally')
# driver.find_element_by_css_selector("div.account-login-wrapper #redhat-account-login-link").click()
# #element.click()
# time.sleep(10)
#
Beispiel #42
0
browser.get('https://www.roblox.com')

print("{0}:{1}:{2}:{3}/{4}-{5}".format(uname,pword,sex,bdaymonth,bdayday,bdayyear),end="", flush=True)

#Ids and classes
username = browser.find_element_by_id("signup-username")
password = browser.find_element_by_id("signup-password")
password2 = browser.find_element_by_id("signup-password-confirm")
#termsofService = browser.find_element_by_xpath("//*[@id="agreeTermsPrivacyLabel"]").click() #//*[@id="agreeTermsPrivacyLabel"]
gender = browser.find_element_by_id(sex+"Button")
month = browser.find_element_by_id("MonthDropdown")
day = browser.find_element_by_id("DayDropdown")
year = browser.find_element_by_id("YearDropdown")

#BDAY:
select = Select(month)
select.select_by_value(bdaymonth)
select = Select(day)
select.select_by_value(bdayday)
select = Select(year)
select.select_by_value(bdayyear)

username.send_keys(uname);
password.send_keys(pword);
password2.send_keys(pword);
gender.click()
browser.find_element_by_xpath('//*[@id="agreeTermsPrivacyLabel"]').click() #//*[@id="agreeTermsPrivacyLabel"]
browser.find_element_by_xpath('//*[@id="signup-button"]').click()

CurrURL = browser.current_url
log(CurrURL)
class MyTestCase(unittest.TestCase):
    userName = "******"
    pwd = "demo@123"
    groupDesc="HelloTest"
    startDate="2019-11-24"
    endDate="2019-11-24"

    @classmethod
    def setUpClass(self):
        self.driver = webdriver.Chrome(executable_path='E:\PythonProjects\SeleniumPythonProject\drivers\chromedriver.exe')
        self.driver.maximize_window()
        self.driver.get("http://saya.incois.gov.in/")

    def login(self):
        self.driver.find_element_by_name('txtActorUserName').send_keys(MyTestCase.userName)
        self.driver.find_element_by_id("txtActorPassword").send_keys(MyTestCase.pwd)
        self.driver.find_element_by_id("btnLogin").click()

    def goToMySignage(self):
        self.actions = ActionChains(self.driver)
        self.mySignage = self.driver.find_element_by_xpath("(//*[@data-toggle='dropdown'])[2]")
        self.actions.move_to_element(self.mySignage).perform()

    def goToMyDisplays(self):
        self.driver.find_element_by_xpath("//span[@class='fa fa-object-group']").click()

    def creategroup(self,value):
        groupName=self.driver.find_element_by_id("txtGroupName")
        groupName.send_keys(value)
        groupName1 = groupName.get_attribute("value")
        print("Attribute is " +groupName1)
        self.driver.find_element_by_id("txtDesc").send_keys(MyTestCase.groupDesc)
        self.driver.find_element_by_id("txtStartDate").send_keys(MyTestCase.startDate)
        time.sleep(1)
        startTime = self.driver.find_element_by_id("txtStartTime")
        self.driver.execute_script("arguments[0].value='00:01:01';", startTime)
        time.sleep(1)
        self.driver.find_element_by_id("txtEndDate").send_keys(MyTestCase.endDate)
        time.sleep(1)
        endTime = self.driver.find_element_by_id("txtEndTime")
        self.driver.execute_script("arguments[0].value='20:59:59';", endTime)
        self.driver.find_element_by_name("btnSave").click()
        return groupName1

    def goToIncoisApps(self,value):
        #self.selectGroupName=self.creategroup()
        print("Created Group Name" +value)
       # time.sleep(2)
        self.goToMySignage()
        self.mySignageIncoisApps = self.mySignage.find_element_by_xpath("//*[contains(text(),' IncoisApps')]").click()
        self.select = Select(self.driver.find_element_by_name("ctl00$ContentPlaceHolder1$ddlGroup"))
        self.select.select_by_visible_text('SG: ' +value)
        self.driver.find_element_by_id("ctl00_ContentPlaceHolder1_btnSearch").click()
        time.sleep(10)
        self.driver.find_element_by_id("ctl00_ContentPlaceHolder1_chkAOIPfz").click()
        time.sleep(5)

    def select_multipleStates(self):
       self.driver.find_element_by_id("ctl00_ContentPlaceHolder1_ddlPfzStates").click()
       time.sleep(3)
       clickMultipleStates = self.addMultipleStates()
       print(clickMultipleStates.__len__())
       for i in clickMultipleStates:
         self.driver.find_element_by_xpath("//span[text()='"+i+"']/../ input[@ type='checkbox']").click()

         # span[text() = '"+i+"'] /../ input[ @ type = 'checkbox']
    def addMultipleStates(self):
           a=[]
           a.append("NORTH TAMILNADU")
           a.append("NICOBAR")
           for states in a:
            print("States are"+states)
           return a

    def test_testCase(self):
        self.login()
        self.goToMySignage()
        self.goToMyDisplays()
        createdGroupName = self.creategroup('HelloTest')
        self.goToIncoisApps(createdGroupName)
        self.select_multipleStates()
Beispiel #44
0
 def test_click_traveller_selection(self):
     enterloginbtn = Select(
         self.driver.find_element_by_id(locators.traveller_selection))
     enterloginbtn.select_by_visible_text(
         Userdata.HotelDetails.get('travel_selection'))
Beispiel #45
0
    def test_add_component(self):
        """Test user adding project and component."""
        user = self.do_login()
        create_billing(user)

        # Open billing page
        self.click(self.driver.find_element_by_id("user-dropdown"))
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_id("billing-button"))
        self.screenshot("user-billing.png")

        # Click on add project
        with self.wait_for_page_load():
            self.click(
                self.driver.find_element_by_class_name("billing-add-project"))

        # Add project
        self.driver.find_element_by_id("id_name").send_keys("WeblateOrg")
        self.driver.find_element_by_id("id_web").send_keys(
            "https://weblate.org/")
        self.driver.find_element_by_id("id_mail").send_keys(
            "*****@*****.**")
        self.driver.find_element_by_id("id_instructions").send_keys(
            "https://weblate.org/contribute/")
        self.screenshot("user-add-project.png")
        with self.wait_for_page_load():
            self.driver.find_element_by_id("id_name").submit()
        self.screenshot("user-add-project-done.png")

        # Click on add component
        with self.wait_for_page_load():
            self.click(
                self.driver.find_element_by_class_name(
                    "project-add-component"))

        # Add component
        self.driver.find_element_by_id("id_name").send_keys("Language names")
        self.driver.find_element_by_id("id_repo").send_keys(
            "https://github.com/WeblateOrg/demo.git")
        self.screenshot("user-add-component-init.png")
        with self.wait_for_page_load(timeout=1200):
            self.driver.find_element_by_id("id_name").submit()

        self.screenshot("user-add-component-discovery.png")
        self.driver.find_element_by_id("id_id_discovery_0_1").click()
        with self.wait_for_page_load(timeout=1200):
            self.driver.find_element_by_id("id_name").submit()

        self.driver.find_element_by_id("id_repoweb").send_keys(
            "https://github.com/WeblateOrg/demo/blob/"
            "{{branch}}/{{filename}}#L{{line}}")
        self.driver.find_element_by_id("id_filemask").send_keys(
            "weblate/langdata/locale/*/LC_MESSAGES/django.po")
        self.driver.find_element_by_id("id_new_base").send_keys(
            "weblate/langdata/locale/django.pot")
        Select(self.driver.find_element_by_id(
            "id_file_format")).select_by_value("po")
        Select(self.driver.find_element_by_id("id_license")).select_by_value(
            "GPL-3.0-or-later")
        self.clear_field(self.driver.find_element_by_id(
            "id_language_regex")).send_keys("^(cs|he|hu)$")
        self.screenshot("user-add-component.png")
Beispiel #46
0
            Html_file.close()


driver = webdriver.Chrome()

driver.get('https://www.library.pref.okinawa.jp/archive/index.html')

driver.find_element_by_class_name("menu02").click()

driver.find_element_by_name("submit_btn_searchDetailAllAr").click()

# 普通にエレメントを取得する
color_element = driver.find_element_by_name('opt_oder')

# 取得したエレメントをSelectタグに対応したエレメントに変化させる
color_select_element = Select(color_element)

# 選択したいvalueを指定する
color_select_element.select_by_value('0')

driver.find_element_by_name("submit_btn_sort").click()

driver.find_element_by_class_name("link-image").click()

save(driver.page_source)

for i in range(2, 1001):
    time.sleep(1)
    if i % 50 == 0:
        print(i)
Beispiel #47
0
    def test_admin(self):
        """Test admin interface."""
        self.do_login(superuser=True)
        self.screenshot("admin-wrench.png")
        self.create_component()
        # Open admin page
        self.open_admin(login=False)

        # Component list
        with self.wait_for_page_load():
            self.click("Component lists")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_class_name("addlink"))
        element = self.driver.find_element_by_id("id_name")
        element.send_keys("All components")
        self.click("Add another Automatic component list assignment")
        self.clear_field(
            self.driver.find_element_by_id(
                "id_autocomponentlist_set-0-project_match")).send_keys("^.*$")
        self.clear_field(
            self.driver.find_element_by_id(
                "id_autocomponentlist_set-0-component_match")).send_keys(
                    "^.*$")
        self.screenshot("componentlist-add.png")
        with self.wait_for_page_load():
            element.submit()

        # Ensure the component list is there
        with self.wait_for_page_load():
            self.click("All components")

        # Whiteboard
        with self.wait_for_page_load():
            self.click("Weblate translations")
        with self.wait_for_page_load():
            self.click("Whiteboard messages")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_class_name("addlink"))
        Select(self.driver.find_element_by_id(
            "id_project")).select_by_visible_text("WeblateOrg")
        element = self.driver.find_element_by_id("id_message")
        element.send_keys("Translations will be used only if they reach 60%.")
        self.screenshot("whiteboard.png")
        with self.wait_for_page_load():
            element.submit()
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_class_name("addlink"))
        Select(self.driver.find_element_by_id(
            "id_language")).select_by_visible_text("Czech")
        element = self.driver.find_element_by_id("id_message")
        element.send_keys("Czech translators rock!")
        with self.wait_for_page_load():
            element.submit()

        # Whiteboard display
        self.view_site()
        self.click("Tools")
        with self.wait_for_page_load():
            self.click("All projects")
        with self.wait_for_page_load():
            self.click("WeblateOrg")
        self.screenshot("whiteboard-project.png")

        with self.wait_for_page_load():
            self.click("Dashboard")
        self.click("Tools")
        with self.wait_for_page_load():
            self.click("All languages")
        with self.wait_for_page_load():
            self.click("Czech")
        self.screenshot("whiteboard-language.png")
Beispiel #48
0
    def test_fonts(self):
        self.create_component()
        self.do_login(superuser=True)
        self.click("Tools")
        with self.wait_for_page_load():
            self.click("All projects")
        with self.wait_for_page_load():
            self.click("WeblateOrg")
        self.click("Manage")
        with self.wait_for_page_load():
            self.click("Fonts")

        self.click(self.driver.find_element_by_id("tab_fonts"))

        # Upload font
        element = self.driver.find_element_by_id("id_font")
        element.send_keys(element._upload(FONT))  # noqa: SF01,SLF001
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_id("upload_font_submit"))

        self.screenshot("font-edit.png")

        with self.wait_for_page_load():
            self.click("Fonts")

        # Upload second font
        element = self.driver.find_element_by_id("id_font")
        element.send_keys(element._upload(SOURCE_FONT))  # noqa: SF01,SLF001
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_id("upload_font_submit"))

        with self.wait_for_page_load():
            self.click("Fonts")

        self.screenshot("font-list.png")

        self.click(self.driver.find_element_by_id("tab_groups"))

        # Create group
        Select(self.driver.find_element_by_id(
            "id_group_font")).select_by_visible_text("Source Sans Pro Bold")
        element = self.driver.find_element_by_id("id_group_name")
        element.send_keys("default-font")
        with self.wait_for_page_load():
            element.submit()

        Select(self.driver.find_element_by_id(
            "id_font")).select_by_visible_text("Droid Sans Fallback Regular")
        element = self.driver.find_element_by_id("id_language")
        Select(element).select_by_visible_text("Japanese")
        with self.wait_for_page_load():
            element.submit()
        Select(self.driver.find_element_by_id(
            "id_font")).select_by_visible_text("Droid Sans Fallback Regular")
        element = self.driver.find_element_by_id("id_language")
        Select(element).select_by_visible_text("Korean")
        with self.wait_for_page_load():
            element.submit()

        self.screenshot("font-group-edit.png")

        with self.wait_for_page_load():
            self.click("Font groups")

        self.screenshot("font-group-list.png")
 def __init__(self, webelement):
     #  WebElementWrapper is created by coping __dict__ of WebElement instance
     #+ in method __new__ of _WebElementWrapper. So there have to be called
     #+ only init method of Select.
     Select.__init__(self, webelement)
Beispiel #50
0
    def test_weblate(self):
        user = self.open_admin()
        language_regex = "^(cs|he|hu)$"

        # Add project
        with self.wait_for_page_load():
            self.click("Projects")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_class_name("addlink"))
        self.driver.find_element_by_id("id_name").send_keys("WeblateOrg")
        Select(self.driver.find_element_by_id(
            "id_access_control")).select_by_value("1")
        self.driver.find_element_by_id("id_web").send_keys(
            "https://weblate.org/")
        self.driver.find_element_by_id("id_mail").send_keys(
            "*****@*****.**")
        self.driver.find_element_by_id("id_instructions").send_keys(
            "https://weblate.org/contribute/")
        self.screenshot("add-project.png")
        with self.wait_for_page_load():
            self.driver.find_element_by_id("id_name").submit()

        # Add bilingual component
        with self.wait_for_page_load():
            self.click("Home")
        with self.wait_for_page_load():
            self.click("Components")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_class_name("addlink"))

        self.driver.find_element_by_id("id_name").send_keys("Language names")
        Select(self.driver.find_element_by_id(
            "id_project")).select_by_visible_text("WeblateOrg")
        self.driver.find_element_by_id("id_repo").send_keys(
            "https://github.com/WeblateOrg/demo.git")
        self.driver.find_element_by_id("id_repoweb").send_keys(
            "https://github.com/WeblateOrg/demo/blob/"
            "{{branch}}/{{filename}}#L{{line}}")
        self.driver.find_element_by_id("id_filemask").send_keys(
            "weblate/langdata/locale/*/LC_MESSAGES/django.po")
        self.driver.find_element_by_id("id_new_base").send_keys(
            "weblate/langdata/locale/django.pot")
        Select(self.driver.find_element_by_id(
            "id_file_format")).select_by_value("po")
        Select(self.driver.find_element_by_id("id_license")).select_by_value(
            "GPL-3.0-or-later")
        self.clear_field(self.driver.find_element_by_id(
            "id_language_regex")).send_keys(language_regex)
        self.screenshot("add-component.png")
        # This takes long
        with self.wait_for_page_load(timeout=1200):
            self.driver.find_element_by_id("id_name").submit()
        with self.wait_for_page_load():
            self.click("Language names")

        # Add monolingual component
        with self.wait_for_page_load():
            self.click("Components")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_class_name("addlink"))
        self.driver.find_element_by_id("id_name").send_keys("Android")
        Select(self.driver.find_element_by_id(
            "id_project")).select_by_visible_text("WeblateOrg")
        self.driver.find_element_by_id("id_repo").send_keys(
            "weblate://weblateorg/language-names")
        self.driver.find_element_by_id("id_filemask").send_keys(
            "app/src/main/res/values-*/strings.xml")
        self.driver.find_element_by_id("id_template").send_keys(
            "app/src/main/res/values/strings.xml")
        Select(self.driver.find_element_by_id(
            "id_file_format")).select_by_value("aresource")
        Select(self.driver.find_element_by_id("id_license")).select_by_value(
            "MIT")
        self.screenshot("add-component-mono.png")
        # This takes long
        with self.wait_for_page_load(timeout=1200):
            self.driver.find_element_by_id("id_name").submit()
        with self.wait_for_page_load():
            self.click("Android")

        # Load Weblate project page
        self.view_site()
        self.click("Tools")
        with self.wait_for_page_load():
            self.click("All projects")
        with self.wait_for_page_load():
            self.click("WeblateOrg")

        self.screenshot("project-overview.png")

        # User management
        self.click("Manage")
        with self.wait_for_page_load():
            self.click("Users")
        element = self.driver.find_element_by_id("id_user")
        element.send_keys("testuser")
        with self.wait_for_page_load():
            element.submit()
        with self.wait_for_page_load():
            self.click("Manage users")
        self.screenshot("manage-users.png")
        self.screenshot("project-access.png")
        # The project is now watched
        self.click("Projects")
        with self.wait_for_page_load():
            self.click("WeblateOrg")

        # Engage page
        self.click("Share")
        with self.wait_for_page_load():
            self.click("Status widgets")
        self.screenshot("promote.png")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_id("engage-link"))
        self.screenshot("engage.png")
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_id("engage-project"))

        # Glossary
        with self.wait_for_page_load():
            self.click("Glossaries")
        with self.wait_for_page_load():
            self.click("Czech")
        self.click("Add new word")
        self.driver.find_element_by_id("id_source").send_keys("language")
        element = self.driver.find_element_by_id("id_target")
        element.send_keys("jazyk")
        with self.wait_for_page_load():
            element.submit()
        self.screenshot("glossary-edit.png")
        self.click("Projects")
        with self.wait_for_page_load():
            self.click("WeblateOrg")
        with self.wait_for_page_load():
            self.click("Glossaries")
        self.screenshot("project-glossaries.png")
        with self.wait_for_page_load():
            self.click("WeblateOrg")

        # Addons
        self.click("Components")
        with self.wait_for_page_load():
            self.click("Language names")
        self.click("Manage")
        with self.wait_for_page_load():
            self.click("Addons")
        self.screenshot("addons.png")
        with self.wait_for_page_load():
            self.click(
                self.driver.find_element_by_xpath(
                    '//button[@data-addon="weblate.discovery.discovery"]'))
        element = self.driver.find_element_by_id("id_match")
        element.send_keys("weblate/locale/(?P<language>[^/]*)/LC_MESSAGES/"
                          "(?P<component>[^/]*)\\.po")
        self.clear_field(self.driver.find_element_by_id(
            "id_language_regex")).send_keys(language_regex)
        self.driver.find_element_by_id("id_new_base_template").send_keys(
            "weblate/locale/{{ component }}.pot")
        self.clear_field(self.driver.find_element_by_id(
            "id_name_template")).send_keys("{{ component|title }}")
        Select(self.driver.find_element_by_id(
            "id_file_format")).select_by_value("po")
        with self.wait_for_page_load():
            element.submit()
        self.screenshot("addon-discovery.png")
        element = self.driver.find_element_by_id("id_confirm")
        self.click(element)
        # This takes long
        with self.wait_for_page_load(timeout=1200):
            element.submit()
        with self.wait_for_page_load():
            self.click("Language names")

        # Reports
        self.click("Insights")
        self.click("Translation reports")
        self.click("Insights")
        self.screenshot("reporting.png")

        # Contributor agreeement
        self.click("Manage")
        with self.wait_for_page_load():
            self.click("Settings")
        element = self.driver.find_element_by_id("id_agreement")
        element.send_keys("This is an agreement.")
        with self.wait_for_page_load():
            element.submit()
        with self.wait_for_page_load():
            self.click("Language names")
        self.screenshot("contributor-agreement.png")
        with self.wait_for_page_load():
            self.click("View contributor agreement")
        element = self.driver.find_element_by_id("id_confirm")
        self.click(element)
        with self.wait_for_page_load():
            element.submit()

        # Translation page
        with self.wait_for_page_load():
            self.click("Czech")
        with self.wait_for_page_load():
            self.click("Django")
        self.screenshot("strings-to-check.png")
        self.click("Files")
        self.click("Upload translation")
        self.click("Files")
        self.screenshot("export-import.png")
        self.click("Tools")
        self.click("Automatic translation")
        self.click(self.driver.find_element_by_id("id_select_auto_source_2"))
        self.click("Tools")
        self.screenshot("automatic-translation.png")
        self.click("Search")
        element = self.driver.find_element_by_id("id_q")
        element.send_keys("%(count)s word")
        with self.wait_for_page_load():
            element.submit()
        self.click("History")
        self.screenshot("format-highlight.png")
        self.click("Comments")
        self.screenshot("plurals.png")

        # Trigger check
        self.clear_field(
            self.driver.find_element_by_id("id_a2a808c8ccbece08_0"))
        element = self.driver.find_element_by_id("id_a2a808c8ccbece08_1")
        self.clear_field(element)
        element.send_keys("několik slov")
        with self.wait_for_page_load():
            element.submit()
        self.screenshot("checks.png")

        # Secondary language display
        user.profile.secondary_languages.set(
            Language.objects.filter(code__in=("he", )))
        with self.wait_for_page_load():
            self.click("Czech")
        with self.wait_for_page_load():
            self.click(
                self.driver.find_element_by_partial_link_text("All strings"))
        self.click("Other languages")
        self.screenshot("secondary-language.png")

        # RTL translation
        with self.wait_for_page_load():
            self.click("Django")
        with self.wait_for_page_load():
            self.click("Hebrew")
        with self.wait_for_page_load():
            self.click(
                self.driver.find_element_by_partial_link_text("All strings"))
        self.screenshot("visual-keyboard.png")

        # Source review
        with self.wait_for_page_load():
            self.click("Django")
        with self.wait_for_page_load():
            self.click("English")
        self.screenshot("source-review.png")
        with self.wait_for_page_load():
            self.click(
                self.driver.find_element_by_partial_link_text("All strings"))
        self.screenshot("source-review-detail.png")
        self.click(self.driver.find_element_by_id("edit-context"))
        time.sleep(0.5)
        self.screenshot("source-review-edit.png")
        # Close modal dialog
        self.driver.find_element_by_id("id_extra_context").send_keys(
            Keys.ESCAPE)
        time.sleep(0.5)

        # Profile
        self.click(self.driver.find_element_by_id("user-dropdown"))
        with self.wait_for_page_load():
            self.click(self.driver.find_element_by_id("settings-button"))
        self.click("Preferences")
        self.screenshot("dashboard-dropdown.png")
        self.click("Notifications")
        self.screenshot("profile-subscriptions.png")
        self.click("Licenses")
        self.screenshot("profile-licenses.png")

        # Dashboard
        with self.wait_for_page_load():
            self.click("Dashboard")
        self.screenshot("your-translations.png")
def Part1_InputBookedInformation(driver, Date, from_station, to_station,
                                 train_no):
    # Get booked Date and Station information and saving into the variable of T_Date and Station respectively
    T_Date, Station = FindBookedDateAndStationsInformation(driver)

    # Input train_no
    Box_train_no = driver.find_element_by_name('train_no')
    Box_train_no.clear()
    Box_train_no.send_keys(train_no)

    # Input persion_id
    Box_person_id = driver.find_element_by_name('person_id')
    Box_person_id.clear()
    Box_person_id.send_keys(person_id)

    # Select Date, the station name of start and destination
    # The Part of Date
    Se_Date = Select(driver.find_element_by_name('getin_date'))
    Se_Date.select_by_index(int(T_Date[Date]))

    # The Part of Start station
    Se_Start = Select(driver.find_element_by_name('from_station'))
    Se_Start.select_by_index(int(Station[from_station]))

    # The Part of Destination
    Se_Destination = Select(driver.find_element_by_name('to_station'))
    Se_Destination.select_by_index(int(Station[to_station]))

    try:
        time.sleep(2)
        N_order = Select(driver.find_element_by_name('n_order_qty_str'))
        N_order.select_by_index(BookNumber)
        # If want to book the table seat, Open below code to do that
        # T_order = Select(driver.find_element_by_name('z_order_qty_str'))
        # T_order.select_by_index(BookNumber)
    except:
        Ori_order = Select(driver.find_element_by_name('order_qty_str'))
        Ori_order.select_by_index(BookNumber - 1)

    Next = driver.find_element_by_class_name('col-xs-12')
    Next.find_element_by_class_name('btn').click()
Beispiel #52
0
#performs a search for text 'Beginner'
#in the left-side menu bar, changes value from More Options to Raw Text
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import time

driver = webdriver.Chrome()
driver.get('https://wiki.python.org/moin/FrontPage')

searchBox= driver.find_element_by_id('searchinput')
searchBox.clear()
searchBox.send_keys("Beginner")
searchBox.send_keys(Keys.RETURN)
time.sleep(5)

#no unique identifier, so last resort is to find by xpath.
select = Select(driver.find_element_by_xpath('//*[@id="sidebar"]/div[3]/ul/li[5]/form/div/select'))

#guessing the relative path: at least 2 levels, a few intermediate levels and a form and div.
#select = Select(driver.find_element_by_xpath('//*/form/div/select'))
select.select_by_visible_text("Raw Text")
time.sleep(5)

driver.close()
Beispiel #53
0
    return str(math.log(abs(12 * math.sin(int(x)))))


# webdriver это и есть набор команд для управления браузером
from selenium import webdriver

# инициализируем драйвер браузера. После этой команды вы должны увидеть новое открытое окно браузера
driver = webdriver.Chrome()

# команда time.sleep устанавливает паузу в 5 секунд, чтобы мы успели увидеть, что происходит в браузере

# Метод get сообщает браузеру, что нужно открыть сайт по указанной ссылке
driver.get("http://suninjuly.github.io/selects1.html")

# Метод find_element_by_css_selector позволяет найти нужный элемент на сайте, указав путь к нему. Способы поиска элементов мы обсудим позже
# Ищем поле для ввода текста
num1 = driver.find_element_by_css_selector("#num1")

num2 = driver.find_element_by_css_selector("#num2")

sum = int(num1.text) + int(num2.text)

select = Select(driver.find_element_by_tag_name("select"))
select.select_by_value(str(sum))  # ищем элемент с текстом "Python"

driver.execute_script("alert('Hello!');")
button = driver.find_element_by_css_selector(".btn-default").click()

time.sleep(5)
# После выполнения всех действий мы не должны забыть закрыть окно браузера
driver.quit()
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import math
from selenium.webdriver.support.ui import Select

try: 
    link = "http://suninjuly.github.io/selects1.html"
    browser = webdriver.Chrome()
    browser.get(link)

    the_sum1 = browser.find_element(By.CSS_SELECTOR, "#num1")
    the_sum2 = browser.find_element(By.CSS_SELECTOR, "#num2")
    the_sum1_text = the_sum1.text
    the_sum2_text = the_sum2.text
    the_sum = int(the_sum1_text) + int(the_sum2_text)
    select = Select(browser.find_element_by_tag_name("select"))
    select.select_by_visible_text(str(the_sum))

    button = browser.find_element(By.CSS_SELECTOR, "button.btn")
    button.click()

finally:
    time.sleep(20)
    browser.quit()
Beispiel #55
0
 def _do():
     elem = self.wait_valid_element(by_loc, wait_time)
     elem.location_once_scrolled_into_view
     select_elem = Select(elem)
     time.sleep(step_time_gap)
     select_elem.select_by_value(value)
Beispiel #56
0
def main():

    driver = makeDriver()

    driver.implicitly_wait(3)

    driver.get('http://www.opinet.co.kr/searRgSelect.do')
    time.sleep(3)

    # 시선택 셀렉트박스에서 서울을 선택
    si_select = Select(driver.find_element_by_id('SIDO_NM0'))
    # 구선택 셀렉트박스에서 강남구를 선택
    gu_select = Select(driver.find_element_by_id('SIGUNGU_NM0'))

    final_oil_price_list = []

    for si_index in range(1, len(si_select.options)):
        si_select = Select(driver.find_element_by_id('SIDO_NM0'))
        gu_select = Select(driver.find_element_by_id('SIGUNGU_NM0'))
        si_select.select_by_index(si_index)
        time.sleep(3)
        for gu_index in range(1, len(gu_select.options)):
            gu_select = Select(driver.find_element_by_id('SIGUNGU_NM0'))
            gu_select.select_by_index(gu_index)
            time.sleep(3)

            html = driver.page_source
            soup = BeautifulSoup(html, 'lxml')

            # soup객체를 통해 데이터 파싱 수행
            # 주유소 기름값 정보를  데이터(list of list)로 확보
            final_oil_price_list.extend(parse_oil_price_per_gu(soup))

    print(final_oil_price_list)
    save_to_file(final_oil_price_list)
    driver.close()
Beispiel #57
0
    def test_ops(self):
        Failflag = False

        validatelist=list()
        driver = self.driver

        sleep(1)

        driver.get(self.base_url + "/index.html")
        sleep(1)

        #print driver.find_element_by_id("overridelink")

        sleep(1)
        driver.find_element_by_name("username").clear()
        driver.find_element_by_name("username").send_keys("administrator")
        driver.find_element_by_name("password").clear()
        driver.find_element_by_name("password").send_keys("password")

        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()

        sleep(1)
        tolog("Verify creating a new user.")
        driver.find_element_by_css_selector("li[name=\"user\"] > a > span.ng-binding.ng-scope").click()

        driver.find_element_by_xpath("(//button[@type='button'])[4]").click()
        sleep(1)
        idname=random_key(10)
        fullname=random_key(15)
        driver.find_element_by_name("id").clear()
        driver.find_element_by_name("id").send_keys(idname)
        driver.find_element_by_name("fulllname").clear()
        driver.find_element_by_name("fulllname").send_keys(fullname)

        pwd=random_key(8)
        driver.find_element_by_name("password").clear()
        driver.find_element_by_name("password").send_keys(pwd)
        driver.find_element_by_name("retypepassword").clear()
        driver.find_element_by_name("retypepassword").send_keys(pwd)
        sleep(1)
        email=address_generator()

        driver.find_element_by_name("email").clear()
        driver.find_element_by_name("email").send_keys(email)


        driver.find_element_by_name("privilege").click()
        sleep(1)
        privilege = ["Super", "Power", "Maintenance", "View"]
        priv="View"

        Select(driver.find_element_by_name("privilege")).select_by_visible_text(priv)
        #driver.find_element_by_css_selector("option[value=\"string:" + priv + "\"]").click()
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()

        for i in range(100):
            try:
                if re.search(r"^[\s\S]*New User was created successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User %s was added successfully." % idname);

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")
        sleep(1)
        validatelist.append(VerifyWords(driver,(idname,fullname,priv,email)))

        tolog("Verify modifying a user's settings.")
        # modify user settings
        sleep(1)
        driver.find_element_by_xpath("(//input[@type='checkbox'])[3]").click()
        sleep(1)
        driver.find_element_by_xpath("(//button[@type='button'])[2]").click()
        sleep(1)
        updatedfullname = "updated_" + fullname
        driver.find_element_by_name("displayname").clear()
        sleep(1)
        driver.find_element_by_name("displayname").send_keys(updatedfullname)
        sleep(1)
        updatedemail="updated_"+email
        driver.find_element_by_name("email").clear()
        sleep(1)
        driver.find_element_by_name("email").send_keys(updatedemail)
        sleep(1)
        privilege.remove(priv)

        updatedpriv=random.choice(privilege)
        # print ("the updatedpriv is %s" % updatedpriv)
        sleep(1)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        sleep(1)
        # driver.find_element_by_css_selector("option[value=\"string:"+updatedpriv+"\"]").click()
        # sleep(1)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        sleep(1)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        sleep(1)
        for i in range(100):
            try:
                if re.search(r"^[\s\S]*User Settings were saved successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User settings %s %s %s were saved successfully." % (updatedfullname,updatedemail,updatedpriv));

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")
        time.sleep(2)
        validatelist.append(VerifyWords(driver, (updatedfullname, updatedemail, updatedpriv)))

        # change password
        tolog("Verify changing a new user's password.")
        driver.find_element_by_xpath("(//input[@type='checkbox'])[3]").click()
        sleep(1)
        driver.find_element_by_xpath("//button[@type='button']").click()
        sleep(1)
        driver.find_element_by_name("newpwd").clear()
        driver.find_element_by_name("newpwd").send_keys("password")
        driver.find_element_by_name("newpwd").clear()
        sleep(1)
        driver.find_element_by_name("newpwd").send_keys("1")
        driver.find_element_by_name("retypepwd").clear()
        driver.find_element_by_name("retypepwd").send_keys("1")
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        sleep(1)
        for i in range(100):
            try:
                if re.search(r"^[\s\S]*User Password was changed successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User Password was changed successfully." );

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")

        tolog("Verify deleting the created user.")
        driver.find_element_by_xpath("(//input[@type='checkbox'])[3]").click()
        sleep(1)
        driver.find_element_by_xpath("(//button[@type='button'])[3]").click()
        sleep(1)
        driver.find_element_by_name("name").clear()
        driver.find_element_by_name("name").send_keys("confirm")
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        sleep(1)
        for i in range(100):
            try:
                if re.search(r"^[\s\S]*User was deleted successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User %s was deleted successfully."%idname);

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")

        for val in validatelist:
            if val:
                Failflag = True
                break

        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #58
0
 def _do():
     elem.location_once_scrolled_into_view
     select_elem = Select(elem)
     time.sleep(step_time_gap)
     select_elem.select_by_value(value)
Beispiel #59
0
from selenium import webdriver
import time

link = "http://suninjuly.github.io/selects2.html"

try:

    browser = webdriver.Chrome()
    browser.get(link)
    res = int(browser.find_element_by_id('num1').text) + int(
        browser.find_element_by_id('num2').text)
    from selenium.webdriver.support.ui import Select
    select = Select(browser.find_element_by_tag_name("select"))
    select.select_by_value(str(res))  # ищем элемент с текстом "res"

    button = browser.find_element_by_css_selector('button')
    button.click()

finally:
    # ожидание чтобы визуально оценить результаты прохождения скрипта
    time.sleep(3)
    # закрываем браузер после всех манипуляций
    browser.quit()
 def selectbillpayaccount(self,accountnumber):
     select = Select(self.Openbrowser.find_element_by_xpath(self.selectfromaccountpayee_xpath))
     select.select_by_visible_text(accountnumber)