コード例 #1
0
ファイル: scrape.py プロジェクト: jrtc27/mytrin-ballot
def get_table(driver):
    form = driver.find_element_by_id('frm_1')
    select = Select(driver.find_element_by_id('sel_court'))
    select.select_by_value('-1') # -1 means all
    # Has no name nor id - have to resort to the fact that it is the only
    # table-like table and thus use a CSS selector
    return driver.find_element_by_css_selector('table.standard_table')
コード例 #2
0
ファイル: common.py プロジェクト: hyteer/work
 def select_button(self, key):
     '''
     运费策略
     '''
     driver = self.conf.driver
     driver.implicitly_wait(10)
     xpath = LC.COMMON[key]
     value = ["0", "1", "2", "3"]
     value0 = random.choice(value)
     number = random.randint(50, 200)
     time.sleep(1)
     ele = Select(driver.find_element_by_xpath(xpath=xpath))
     ele.select_by_value(value0)
     time.sleep(1)
     if value0 == "2":
         # 输入订单的满减金额
         xpath1 = '//*[@id="rule"]/form/div[6]/div/input'
         ele1 = WebDriverWait(driver, 20).until(lambda x: x.find_element_by_xpath(xpath=xpath1))
         time.sleep(1)
         ele1.send_keys(number)
         time.sleep(1)
     elif value0 == "3":
         # 输入订单的满减金额
         xpath2 = '//*[@id="rule"]/form/div[7]/div/input'
         ele1 = WebDriverWait(driver, 20).until(lambda x: x.find_element_by_xpath(xpath=xpath2))
         time.sleep(1)
         ele1.send_keys(number)
         time.sleep(0.5)
     else:
         time.sleep(0.5)
コード例 #3
0
ファイル: library.py プロジェクト: AlexxNica/edx-platform
 def set_select_value(self, label, value):
     """
     Sets the select with given label (display name) to the specified value
     """
     elem = self.get_setting_element(label)
     select = Select(elem)
     select.select_by_value(value)
コード例 #4
0
class EditAddOrganiztionPageCMS(BasePageCMS):
     
    def __init__(self, driver, wait):
        self.driver = driver
        self.wait = wait
        self.name = self.wait.until(lambda driver : driver.find_element_by_id("id_name"))
        self.parent = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_parent")))
        self.lmSite = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_lmsite")))
    
    def typeName(self, name):
        self.name.send_keys(name)
        
    def selectParent(self, parent):
        self.parent.select_by_visible_text(parent)
    
    def selectLmSite(self, site):
        self.lmSite.select_by_visible_text(site)
    
    def clickSaveAndContinueEditingButton(self):
        self.clickSaveAndContinueEditing()
        return EditAddOrganiztionPageCMS(self.driver, self.wait)
    
    def getName(self):
        return self.name.get_attribute("value")
    
    def getSelectedParent(self):
        return self.parent.first_selected_option.text
    
    def getSelectedLmSite(self):
        return self.lmSite.first_selected_option.text
    
    def clickObjectPermissions(self):
        self.clickOnLink("Object permissions")
        return OrganizationObjectPermissionsCMS(self.driver, self.wait)
コード例 #5
0
ファイル: helpers.py プロジェクト: chauhanhardik/populo
def select_option_by_value(browser_query, value):
    """
    Selects a html select element by matching value attribute
    """
    select = Select(browser_query.first.results[0])
    select.select_by_value(value)

    def options_selected():
        """
        Returns True if all options in select element where value attribute
        matches `value`. if any option is not selected then returns False
        and select it. if value is not an option choice then it returns False.
        """
        all_options_selected = True
        has_option = False
        for opt in select.options:
            if opt.get_attribute('value') == value:
                has_option = True
                if not opt.is_selected():
                    all_options_selected = False
                    opt.click()
        # if value is not an option choice then it should return false
        if all_options_selected and not has_option:
            all_options_selected = False
        return all_options_selected

    # Make sure specified option is actually selected
    EmptyPromise(options_selected, "Option is selected").fulfill()
コード例 #6
0
ファイル: tests.py プロジェクト: glic3rinu/django-orchestra
    def add(self, name, password, admin_email, address_name=None, address_domain=None):
        url = self.live_server_url + reverse("admin:lists_list_add")
        self.selenium.get(url)

        name_field = self.selenium.find_element_by_id("id_name")
        name_field.send_keys(name)

        password_field = self.selenium.find_element_by_id("id_password1")
        password_field.send_keys(password)
        password_field = self.selenium.find_element_by_id("id_password2")
        password_field.send_keys(password)

        admin_email_field = self.selenium.find_element_by_id("id_admin_email")
        admin_email_field.send_keys(admin_email)

        if address_name:
            address_name_field = self.selenium.find_element_by_id("id_address_name")
            address_name_field.send_keys(address_name)

            domain = Domain.objects.get(name=address_domain)
            domain_input = self.selenium.find_element_by_id("id_address_domain")
            domain_select = Select(domain_input)
            domain_select.select_by_value(str(domain.pk))

        name_field.submit()
        self.assertNotEqual(url, self.selenium.current_url)
コード例 #7
0
ファイル: VPSBuyer.py プロジェクト: Skynet2-0/Skynet2.0
 def chooseSelectElement(self, fieldName, fieldText):
     """
     Chooses one of the elements in a select list, by its visible text
     """
     select = Select(self.driver.find_element_by_name(fieldName));
     #select.deselect_all()
     select.select_by_visible_text(fieldText)
コード例 #8
0
 def __init__(self, driver, wait, noPageLoad=None):
     self.driver = driver
     self.wait = wait
     if(noPageLoad==None):
         self.driver.get(ServerRelated().serverToBeTested() + "admin/cms/contentproject/dashboard/")
     self.uploadDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_upload_media")))
     self.createDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_create_content")))
コード例 #9
0
ファイル: __init__.py プロジェクト: mcallaghan/scrapeWoS
def downloadChunk( link, browser, rFrom, rTo, i ):
    try :
        close = browser.find_element_by_xpath("//a[@class='quickoutput-cancel-action']")  #close previous download box
        close.click()
    except :
        pass

    fFrom = str(rFrom)
    rTo = str(rTo)

    browser.execute_script("window.scrollTo(0, 0);")
    #time.sleep(1)
    browser.find_element_by_xpath("//div[@id='s2id_saveToMenu']//b").click()  #save to arrow

    if i == 1:
        browser.find_element_by_id('select2-result-label-12').click()  #save to other formats
    else :
        browser.find_element_by_id('select2-chosen-1').click()  #save to other formats

    browser.find_element_by_id('numberOfRecordsRange').click()  #select records range
    browser.find_element_by_id('markFrom').click()  #click on from box
    browser.find_element_by_id('markFrom').send_keys(fFrom)  #enter keys in from box
    browser.find_element_by_id('markTo').click()  #click on to box
    browser.find_element_by_id('markTo').send_keys(rTo)  #enter keys in to box

    dropdown = browser.find_element_by_id('bib_fields')  #find fields dropdown
    select_box = Select(dropdown)
    select_box.select_by_index(3)  #select option 3 (all records and refs)

    browser.find_element_by_xpath("//span[@class='quickoutput-action']").click()  #click send
コード例 #10
0
ファイル: Main.py プロジェクト: Chochu/PythonScript
def ChangeServer():
    select = Select(driver.find_element_by_id('selectServer'))

    # select by visible text
    openLoad_link = select.select_by_visible_text('Openload').get_attribute("value")
    driver.get(openLoad_link)
    WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.ID, 'centerDivVideo')))
コード例 #11
0
class DashboardPageCMS(BasePageCMS):
    
    def __init__(self, driver, wait, noPageLoad=None):
        self.driver = driver
        self.wait = wait
        if(noPageLoad==None):
            self.driver.get(ServerRelated().serverToBeTested() + "admin/cms/contentproject/dashboard/")
        self.uploadDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_upload_media")))
        self.createDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_create_content")))
    
    def selectUploadMediaByText(self, media):
        self.uploadDropdown.select_by_visible_text(media)
    
    def selectCreateUser(self):
        self.createDropdown.select_by_visible_text("User")
        return OrganizationUsersPageCMS(self.driver, self.wait)
    
    def getNumberOfVisibleContentProjects(self):
        self.contProjects = self.wait.until(lambda driver : driver.find_elements_by_xpath("//li[contains(text(),'Content Projects')]/ul/li"))
        return len(self.contProjects)
    
    def clickModifyStationModule(self):
        self.clickOnLink("Modify Station Module")
        return EditAddStationModulePageCMS(self.driver, self.wait)

    def clickUsersLink(self):
        self.clickOnLink("Users")
        return OrganizationUsersPageCMS(self.driver, self.wait)

    def getTitlesFromDashboard(self):
        dashboardTitles = self.wait.until(lambda driver : driver.find_elements_by_xpath("//tbody[@id='content_items_table_body']/tr/td[@class='original']"))
        titles = []
        for element in dashboardTitles:
            titles.append(element.text)
        return titles
コード例 #12
0
ファイル: base_page.py プロジェクト: stephendonner/socorro
        def select_report(self, report_name):
            '''
                Select the report type from the drop down
                and wait for the page to reload
            '''
            report_dropdown = self.find_element(*self._report_select_locator)
            select = Select(report_dropdown)
            select.select_by_visible_text(report_name)

            if 'Top Crashers' == report_name:
                from pages.crash_stats_top_crashers_page import CrashStatsTopCrashers
                page = CrashStatsTopCrashers(self.selenium, self.page.base_url)
                return page.wait_for_page_to_load()
            elif 'Top Crashers by TopSite' == report_name:
                from pages.crash_stats_top_crashers_by_site_page import CrashStatsTopCrashersBySite
                page = CrashStatsTopCrashersBySite(self.selenium, self.page.base_url)
                return page.wait_for_page_to_load()
            elif 'Crashes per Day' == report_name:
                from pages.crash_stats_per_day import CrashStatsPerDay
                page = CrashStatsPerDay(self.selenium, self.page.base_url)
                return page.wait_for_page_to_load()
            elif 'Nightly Builds' == report_name:
                from pages.crash_stats_nightly_builds_page import CrashStatsNightlyBuilds
                page = CrashStatsNightlyBuilds(self.selenium, self.page.base_url)
                return page.wait_for_page_to_load()
コード例 #13
0
ファイル: base_page.py プロジェクト: stephendonner/socorro
 def select_product(self, application):
     '''
         Select the Mozilla Product you want to report on
     '''
     element = self.find_element(*self._product_select_locator)
     select = Select(element)
     return select.select_by_visible_text(application)
コード例 #14
0
ファイル: base_page.py プロジェクト: stephendonner/socorro
 def select_version(self, version):
     '''
         Select the version of the application you want to report on
     '''
     version_dropdown = self.find_element(*self._all_versions_locator)
     select = Select(version_dropdown)
     select.select_by_visible_text(str(version))
コード例 #15
0
ファイル: base_page.py プロジェクト: stephendonner/socorro
 def select_version_by_index(self, index):
     '''
         Select the version of the application you want to report on
     '''
     version_dropdown = self.find_element(*self._all_versions_locator)
     select = Select(version_dropdown)
     select.select_by_index(index)
コード例 #16
0
 def edit_management_system(self, management_system):
     for key,value in management_system.iteritems():
         # Special cases
         if "host_vnc_port" in key:
             self.host_default_vnc_port_start.clear()
             self.host_default_vnc_port_start.send_keys(value["start"])
             self.host_default_vnc_port_end.clear()
             self.host_default_vnc_port_end.send_keys(value["end"])
         elif "server_zone" in key:
             from selenium.webdriver.support.select import Select
             if self.server_zone.tag_name == "select":
                 select = Select(self.server_zone)
                 select.select_by_visible_text(value)
         elif "credentials" in key:
             # use credentials
             credentials = self.testsetup.credentials[value]
             self.default_userid.clear()
             self.default_userid.send_keys(credentials['username'])
             self.default_password.clear()
             self.default_password.send_keys(credentials['password'])
             self.default_verify.clear()
             self.default_verify.send_keys(credentials['password'])
         else:
             # Only try to send keys if there is actually a property
             if hasattr(self, key):
                 attr = getattr(self, key)
                 attr.clear()
                 attr.send_keys(value)
     return self.click_on_save()
コード例 #17
0
    def create_run(self, name='Test Run', product_version='Test Product Test Version', desc='This is a test run', start_date='2011-01-01', end_date='2012-12-31', suite_list=None, series_run=False):
        dt_string = datetime.utcnow().isoformat()
        run = {}
        run['name'] = u'%(name)s %(dt_string)s' % {'name': name, 'dt_string': dt_string}
        run['desc'] = u'%(desc)s created on %(dt_string)s' % {'desc': desc, 'dt_string': dt_string}
        run['series'] = series_run
        run['manage_locator'] = (self._run_manage_locator[0], self._run_manage_locator[1] % {'run_name': run['name']})
        run['homepage_locator'] = (self._run_homepage_locator[0], self._run_homepage_locator[1] % {'run_name': run['name']})
        run['run_tests_locator'] = self._run_tests_button_locator

        name_field = self.selenium.find_element(*self._name_locator)
        name_field.send_keys(run['name'])

        series_element = self.selenium.find_element(*self._series_run_locator)

        if series_element.is_selected():
            if not series_run:
                series_element.click()
        else:
            if series_run:
                series_element.click()

        product_version_select = Select(self.selenium.find_element(*self._product_version_select_locator))
        product_version_select.select_by_visible_text(product_version)

        self.selenium.find_element(*self._description_locator).send_keys(run['desc'])

        self.type_in_element(self._start_date_locator, start_date)
        self.selenium.find_element(*self._end_date_locator).send_keys(end_date)

        if suite_list:
            self.multiselect_widget.include_items(suite_list)
        self.selenium.find_element(*self._submit_locator).click()

        return run
コード例 #18
0
ファイル: bulk_csv_cms.py プロジェクト: cbalea/LM-AUTOMATION
class EditBulkCSVFile(BasePageCMS):

    def __init__(self, driver, wait):
        self.driver = driver
        self.wait = wait
        self.contentProject = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_content_project")))
        self.sourceFile = self.wait.until(lambda driver : driver.find_element_by_id("id_file"))
        self.uploadStatus = self.wait.until(lambda driver : driver.find_element_by_xpath("//div/label[text()='Bulk upload status:']/../p"))
    
    def selectContentProjectByIndex(self, index):
        self.contentProject.select_by_index(index)
        
    def typeSourceFile(self, filePath):
        self.sourceFile.send_keys(filePath)
    
    def clickSaveAndContinueEditingButton(self):
        self.clickSaveAndContinueEditing()
        return EditBulkCSVFile(self.driver, self.wait)
    
    def clickImportItButton(self):
        self.clickOnLink("Import it")
        return EditBulkCSVFile(self.driver, self.wait)
    
    def getContentProject(self):
        return self.contentProject.first_selected_option.text
    
    def getCurrentSourceFile(self):
        currentFile = self.wait.until(lambda driver : driver.find_element_by_xpath("//div/label[text()='Source file:']/../p/a"))
        return currentFile.text
    
    def getUploadStatus(self):
        return self.uploadStatus.text
コード例 #19
0
ファイル: BasketExhibit.py プロジェクト: mmguzman/Xinet
 def select_report_preview_option(self, report_name):
     """
     Selects the report preview option.
     :param report_name: Type of report to select.
     """
     select = Select(self._driver.find_element(*self._report_preview_combobox))
     select.select_by_visible_text(report_name)
コード例 #20
0
class UsersReportCMS(ReportsBaseCMS):
    
    organization_dropdown_id = "id_team__organization__name"
    
    def __init__(self, driver, wait, report=None):
        self.driver = driver
        self.wait = wait
        if(report == None):
            self.driver.get(ServerRelated().serverToBeTested() + "admin/reports/user-report/")
        self.groupByField = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_groupby")))
        self.contentProjectDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_team__organization__contentproject__title")))


    def selectGroupByField(self, option):
        self.groupByField.select_by_visible_text(option)
        
    def selectOrganizationByValue(self, text):
        organization = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_team__organization__name")))
        organization.select_by_visible_text(text)
    
    def clickGetResultsButton(self):
        self.clickGetResults()
        return UsersReportCMS(self.driver, self.wait, "report")    
    
    def getContentProjectOptions(self):
        options = self.getOptionsTextInCombobox(self.contentProjectDropdown)
        options.remove("---------")
        return options
        
コード例 #21
0
 def adv_select_version(self, version):
     element = self.selenium.find_element(*self._multiple_version_select_locator)
     # Before trying to select the option we'll try and find it.
     # If it doesn't exist we'll gladly take an exception. Se issue 3910
     element.find_element(By.XPATH, ".//option[normalize-space(.) = '%s']" % version)
     select = Select(element)
     select.select_by_visible_text(version)
コード例 #22
0
 def remove_from_group(self, contact, group):
     wd = self.app.wd
     self.load_home_page()
     select = Select(wd.find_element_by_name("group"))
     select.select_by_visible_text(group.name.strip())
     self.select_by_id(contact.id)
     wd.find_element_by_name("remove").click()
コード例 #23
0
ファイル: WebDriverExt.py プロジェクト: vitekes/quotes
 def select_from_list(self, element=None, value=None):
     locator, _type = element
     if not self.wait_element(element):
         allure.attach('screenshot', self.driver.get_screenshot_as_png(), type=AttachmentType.PNG)
         pytest.fail("element {} not found".format(locator))
     select = Select(self.driver.find_element(by=_type, value=locator))
     select.select_by_value(value)
コード例 #24
0
ファイル: eskypl_tests.py プロジェクト: dankon/eskypl_tests
def fill_payments_form(payments_form, 
                       first_name, 
                       last_name, 
                       gender, 
                       phone_number, 
                       email_address, 
#                        birthday_date
                       ):
    """
    Function for fill up payments form.
    Params: 
    # first_name, 
    # last_name, 
    # gender - value "mrs" means female and "mr" means male, 
    # phone_number, 
    # email_address.
    """
#      birthday_date
#     """
    _genders = [u"mrs", u"mr"]
    if not gender in _genders:
        raise Exception('Bad gender value %s - please choose from %s' % (gender, _genders))
    payments_form.find_element_by_id("bookFlight_paxes_1_name").send_keys(first_name)
    payments_form.find_element_by_id("bookFlight_paxes_1_surname").send_keys(last_name)
    gender_select = Select(payments_form.find_element_by_id("bookFlight_paxes_1_title"))
    gender_select.select_by_value(gender)
    payments_form.find_element_by_id("bookFlight_contactDetails_phoneNumber_phoneNumber")\
        .send_keys(phone_number)
    payments_form.find_element_by_id("bookFlight_contactDetails_email").send_keys(email_address)
    payments_form.find_element_by_id("bookFlight_statute").click()
コード例 #25
0
ファイル: base.py プロジェクト: CDE-UNIBE/qcat
    def add_advanced_filter(self, key: str, value: str) -> None:
        """Add a new advanced filter"""

        # Toggle the filter panel if it is not open yet
        self.toggle_selected_advanced_filters(display=True)

        # Select the last <select> available
        filter_row_xpath = '(//div[contains(@class, "selected-advanced-filters")]/div[contains(@class, "js-filter-item")])[last()]'
        filter_row = self.findBy('xpath', filter_row_xpath)
        filter_select_xpath = f'//select[contains(@class, "filter-key-select")]'
        select = Select(self.findBy('xpath', filter_select_xpath, base=filter_row))

        # If it already has a key selected, click "add filter" to add a new row
        # and select the <select> again
        if select.first_selected_option.text != '---':
            self.findBy('id', 'filter-add-new').click()
            filter_row = self.findBy('xpath', filter_row_xpath)
            select = Select(
                self.findBy('xpath', filter_select_xpath, base=filter_row))

        # Select the key, wait for the values to be loaded and select one
        select.select_by_value(key)
        self.wait_for('xpath', filter_row_xpath + '//div[contains(@class, "loading-indicator-filter-key")]', visibility=False)
        self.findBy('xpath', f'//div[contains(@class, "filter-value-column")]//input[@value="{value}"]', base=filter_row).click()
        self.apply_filter()
コード例 #26
0
ファイル: aq.py プロジェクト: h3y4w/Quizlet-Automator
	def do_speller (self):
		driver = self.driver
		answer_dict = self.answer_dict

		speller_url = self.url + self.assignment_number + '/speller'
		driver.get(speller_url)
		
		select_speed = Select(driver.find_element_by_id('speller-prompt'))
		select_speed.select_by_visible_text("Don't Speak")
		try:
			alert = driver.switch_to_alert()
			alert.accept()
		except NoAlertPresentException:
			pass
		driver.implicitly_wait(3)
		counter = 0
		while True:
			try:
				driver.implicitly_wait(3)
				question=driver.find_element_by_css_selector("*[class^='qDef lang-en TermText']").text
				inputA = driver.find_element_by_id('speller-inp')
				time.sleep(.5)
				try: # this throws an exception when its done
					inputA.click()
				except: #specify element is not visible exception
					self.speak_remainder.run('Finished Speller')
					break
				inputA.clear()
				inputA.send_keys(answer_dict[question])
				inputA.send_keys(Keys.RETURN)
				driver.get(speller_url)
				completed = driver.find_element_by_id('overall-percent').text
				 
				try:
					completed = int(completed.replace('%', ''))
					if completed % 10 == 0 and completed != 0: 
						phrase = completed + ' completed'
						self.speak_remainder.run(phrase) 
				except ValueError:
					continue
				except TypeError:
					continue

			except TimeoutException:
				print 'Timeout'
				continue

			except NoSuchElementException:
				counter += 1
				try:
					if driver.find_element_by_id('game-over').text != "":
						self.speak_remainder.run('Finished Speller')
						break
				except NoSuchElementException:
					continue
				if counter == 3:
					print 'stuck'
				else:
					print 'Reloading'	
					continue
コード例 #27
0
ファイル: base_page.py プロジェクト: AlinT/Socorro-Tests
        def select_report(self, report_name):
            """
                Select the report type from the drop down
                and wait for the page to reload
            """
            report_dropdown = self.selenium.find_element(*self._report_select_locator)
            select = Select(report_dropdown)
            select.select_by_visible_text(report_name)

            if "Top Crashers" == report_name:
                from pages.crash_stats_top_crashers_page import CrashStatsTopCrashers

                return CrashStatsTopCrashers(self.testsetup)
            elif "Top Crashers by TopSite" == report_name:
                from pages.crash_stats_top_crashers_by_site_page import CrashStatsTopCrashersBySite

                return CrashStatsTopCrashersBySite(self.testsetup)
            elif "Crashes per User" == report_name:
                from pages.crash_stats_per_active_daily_user_page import CrashStatsPerActiveDailyUser

                return CrashStatsPerActiveDailyUser(self.testsetup)
            elif "Nightly Builds" == report_name:
                from pages.crash_stats_nightly_builds_page import CrashStatsNightlyBuilds

                return CrashStatsNightlyBuilds(self.testsetup)
            elif "Top Changers" == report_name:
                from pages.crash_stats_top_changers_page import CrashStatsTopChangers

                return CrashStatsTopChangers(self.testsetup)
コード例 #28
0
 def add_to_group(self, contact, group):
     wd = self.app.wd
     self.load_home_page()
     self.select_by_id(contact.id)
     select = Select(wd.find_element_by_name("to_group"))
     select.select_by_visible_text(group.name.strip())
     wd.find_element_by_name("add").click()
コード例 #29
0
ファイル: base_page.py プロジェクト: agustincatalano/py_frame
 def select_drop_down(self, drop_down_locator, value):
     element = self.find_clickable_element(drop_down_locator)
     if element:
         my_select = Select(element)
         my_select.select_by_value(value)
     else:
         raise Exception('Unable to find drop down with locator %s' % str(drop_down_locator))
コード例 #30
0
def contactInfo(driver, downArrowXpath, contName1Field, ddContactType,ddContactTypeTitleXpath, contPhone1Field,
                contWebSite1Field):
    driver.find_element_by_xpath(downArrowXpath).click()
    driver.implicitly_wait(3)
    #filling Contact Name 1
    contNameRandom = randomHelper.random_string_generator()
    driver.find_element_by_xpath(contName1Field).send_keys(contNameRandom)

    # select Contact Type 1
    selectRandomValue = Select(driver.find_element_by_xpath(ddContactType))
    ddContactTypeTitle = driver.find_element_by_xpath(ddContactTypeTitleXpath).text
    a = [o.get_attribute('text') for o in selectRandomValue.options]
    randomValue = (random.choice(a))
    randomValue = str(randomValue)
    selectRandomValue.select_by_visible_text(randomValue)
    print('Selected ' + ddContactTypeTitle + ' is ' + randomValue)

    # filling Contact Phone 1
    contPhoneRandom = randomHelper.random_int_generator()
    driver.find_element_by_xpath(contPhone1Field).send_keys(contPhoneRandom)


    #filling Contact Website 1
    contWebSite1Random = randomHelper.random_string_generator() + '.com'
    driver.find_element_by_xpath(contWebSite1Field).send_keys(contWebSite1Random)
コード例 #31
0
 def public_address_select(self):
     '''Floating Public IP - Openstack'''
     return Select(
         self.get_element(*self. _public_ip_address_select_locator))
コード例 #32
0
 def select_by_index(self, locator, index=0):
     """通过索引,index是索引第几个,从0开始,默认选第一个"""
     element = self.find_element(locator)
     Select(element).select_by_index(index)
     element.click()
コード例 #33
0
 def select_by_text(self, loc, text):
     """通过文本值定位"""
     element = self.find_element(*loc)
     Select(element).select_by_visible_text(text)
コード例 #34
0
 def select_by_value(self, loc, value):
     """通过value属性"""
     element = self.find_element(*loc)
     Select(element).select_by_value(value)
コード例 #35
0
 def select_by_index(self, loc, index):
     """通过索引, index是索引第几个,从0开始"""
     element = self.find_element(*loc)
     Select(element).select_by_index(index)
コード例 #36
0
ファイル: create_task.py プロジェクト: chenchenphoebe/base
 def PC_name(self, pc_name):
     var = Select(self.find_element(*self.pc_name_loc))
     var.select_by_visible_text(pc_name)
コード例 #37
0
ファイル: create_task.py プロジェクト: chenchenphoebe/base
 def scripts_num_display(self):
     var = Select(self.find_element(*self.scripts_num_loc))
     var.select_by_visible_text("25")
コード例 #38
0
 def guest_access_select(self):
     '''Key Pair'''
     return Select(
         self.get_element(*self._guest_access_select_locator))
コード例 #39
0
ファイル: test_views.py プロジェクト: deborahlow97/ontask_b
    def template_merge(self, method, rename=True):
        # Login
        self.login('*****@*****.**')

        # GO TO THE WORKFLOW PAGE
        self.access_workflow_from_home_page(self.wf_name)

        # Go to the upload/merge page
        self.go_to_upload_merge()

        # Dataops/Merge CSV Merge Step 1
        self.selenium.find_element_by_link_text("CSV").click()
        WebDriverWait(self.selenium, 10).until(
            EC.title_is('OnTask :: Upload/Merge CSV')
        )
        self.selenium.find_element_by_id(
            'id_data_file').send_keys(self.merge_file)

        # Click the NEXT button
        self.selenium.find_element_by_xpath(
            "//button[@type='Submit']"
        ).click()
        self.wait_for_page()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//input[@id='id_new_name_0']")
            )
        )

        # Dataops/Merge CSV Merge Step 2
        if rename:
            # Rename the column
            self.selenium.find_element_by_id('id_new_name_0').send_keys('2')

        # Click the NEXT button
        self.selenium.find_element_by_xpath(
            "//button[@type='Submit']"
        ).click()
        self.wait_for_page()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//select[@id='id_dst_key']")
            )
        )

        # Dataops/Merge CSV Merge Step 3
        # Select left merge
        Select(self.selenium.find_element_by_id(
            'id_how_merge'
        )).select_by_value(method)

        # Click the NEXT button
        self.selenium.find_element_by_xpath(
            "//button[@type='Submit']"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Review and confirm')
        )

        # Dataops/Merge CSV Merge Step 4
        # Click in Finish
        self.selenium.find_element_by_xpath(
            "//button[normalize-space()='Finish']"
        ).click()
        self.wait_for_datatable('table-data_previous')
コード例 #40
0
 def cloud_watch_selector(self):
     '''Cloud Watch monitoring'''
     return Select(self.get_element(*self._cloud_watch_select_locator))
コード例 #41
0
ファイル: test_views.py プロジェクト: deborahlow97/ontask_b
    def test_01_first_plugin(self):
        # Login
        self.login('*****@*****.**')

        # GO TO THE WORKFLOW PAGE
        self.access_workflow_from_home_page('Plugin test')

        # Open the transform page
        self.go_to_transform()

        # Click in the first plugin
        element = self.search_table_row_by_string('transform-table',
                                                  1,
                                                  'Test Plugin 1 Name')
        element.find_element_by_link_text('Test Plugin 1 Name').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.NAME, 'csrfmiddlewaretoken'))
        )
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//input[@type='text']"))
        )

        # Provide the execution data
        self.selenium.find_element_by_xpath("//input[@type='text']").click()
        self.selenium.find_element_by_name("columns").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[2]"
        ).click()

        # Select the merge key
        self.select_plugin_output_tab()

        self.selenium.find_element_by_id("id_merge_key").click()
        Select(self.selenium.find_element_by_id(
            "id_merge_key"
        )).select_by_visible_text("email")

        # Submit the execution
        self.selenium.find_element_by_name("Submit").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Plugin scheduled for execution')
        )

        # There should be a message on that page
        self.assertTrue(
            self.selenium.find_element_by_xpath(
                "//div[@id='plugin-run-done']/div/a"
            ).text.startswith(
                'You may check the status in log number'
            )
        )

        # Assert the content of the dataframe
        wflow = Workflow.objects.get(name='Plugin test')
        self.assertTrue(is_column_in_table(wflow.get_data_frame_table_name(),
                                           'RESULT 1'))
        self.assertTrue(is_column_in_table(wflow.get_data_frame_table_name(),
                                           'RESULT 2'))
        df = load_table(wflow.get_data_frame_table_name())
        self.assertTrue(all([x == 1 for x in df['RESULT 1']]))
        self.assertTrue(all([x == 2 for x in df['RESULT 2']]))

        # Second execution, this time adding a suffix to the column
        self.go_to_actions()
        self.go_to_transform()

        # Click in the first plugin
        element = self.search_table_row_by_string('transform-table',
                                                  1,
                                                  'Test Plugin 1 Name')
        element.find_element_by_link_text('Test Plugin 1 Name').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.NAME, 'csrfmiddlewaretoken'))
        )
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//input[@type='text']"))
        )

        # Provide the execution data
        self.selenium.find_element_by_xpath("//input[@type='text']").click()
        # Wait for the column eleemnt to open
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.NAME, "columns"),
            )
        )
        self.selenium.find_element_by_name("columns").click()
        self.selenium.find_element_by_xpath(
            "(//input[@name='columns'])[2]"
        ).click()

        # Select the merge key
        self.select_plugin_output_tab()
        self.selenium.find_element_by_id("id_merge_key").click()
        Select(self.selenium.find_element_by_id(
            "id_merge_key"
        )).select_by_visible_text("email")

        # Put the suffix _2
        self.selenium.find_element_by_id("id_out_column_suffix").click()
        self.selenium.find_element_by_id("id_out_column_suffix").clear()
        self.selenium.find_element_by_id(
            "id_out_column_suffix").send_keys("_2")

        # Submit the execution
        self.selenium.find_element_by_name("Submit").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Plugin scheduled for execution')
        )

        # There should be a message on that page
        self.assertTrue(
            self.selenium.find_element_by_xpath(
                "//div[@id='plugin-run-done']/div/a"
            ).text.startswith(
                'You may check the status in log number'
            )
        )

        # Assert the content of the dataframe
        wflow = Workflow.objects.get(name='Plugin test')
        self.assertTrue(is_column_in_table(wflow.get_data_frame_table_name(),
                                           'RESULT 1_2'))
        self.assertTrue(is_column_in_table(wflow.get_data_frame_table_name(),
                                           'RESULT 2_2'))
        df = load_table(wflow.get_data_frame_table_name())
        self.assertTrue(all([x == 1 for x in df['RESULT 1_2']]))
        self.assertTrue(all([x == 2 for x in df['RESULT 2_2']]))

        assert check_wf_df(Workflow.objects.get(name='Plugin test'))

        # End of session
        self.logout()
コード例 #42
0
 def instance_type_select(self):
     '''Type of instance to provision'''
     return Select(
         self.get_element(*self._instance_type_select_locator))
コード例 #43
0
ファイル: test_views.py プロジェクト: deborahlow97/ontask_b
    def test_01_symbols(self):
        symbols = '!#$%&()*+,-./\\:;<=>?@[]^_`{|}~'

        # Login
        self.login('*****@*****.**')

        # Open the workflow
        self.access_workflow_from_home_page('sss')

        # Go to the column details
        self.go_to_details()

        # Edit the name column
        self.open_column_edit('name')

        # Replace name by symbols
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys(symbols)

        # Click in the submit/save button
        self.selenium.find_element_by_xpath("//button[@type='submit']").click()
        # MODAL WAITING
        self.wait_close_modal_refresh_table('column-table_previous')

        # Click on the Add Column button
        self.open_add_regular_column()

        # Set name to symbols (new column) and type to string
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys(symbols)
        self.selenium.find_element_by_id("id_data_type").click()
        Select(self.selenium.find_element_by_id(
            "id_data_type"
        )).select_by_visible_text("string")

        # Save the new column
        self.selenium.find_element_by_xpath("//button[@type='submit']").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'error_1_id_name')))

        # There should be a message saying that the name of this column already
        # exists
        self.assertIn('There is a column already with this name',
                      self.selenium.page_source)

        # Click again in the name and introduce something different
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").clear()
        self.selenium.find_element_by_id("id_name").send_keys(symbols + '2')

        # Save the new column
        self.selenium.find_element_by_xpath("//button[@type='submit']").click()
        self.wait_close_modal_refresh_table('column-table_previous')

        # Click in the attributes section
        self.go_to_attribute_page()

        # Delete the existing one and confirm deletion
        # click the delete button in the second row
        self.selenium.find_element_by_xpath(
            '//table[@id="attribute-table"]'
            '//tr[1]/td[3]//button[contains(@class, "js-attribute-delete")]'
        ).click()
        # Click in the delete confirm button
        self.selenium.find_element_by_xpath(
            "//div[@id = 'modal-item']//div[@class = 'modal-footer']/button"
        ).click()
        # MODAL WAITING
        self.wait_for_page(element_id='workflow-detail')

        # Add a new attribute and insert key (symbols) and value
        self.create_attribute(symbols + '3', 'vvv')

        # Click in the TABLE link
        self.go_to_table()

        # Verify that everything appears normally
        self.assertIn(escape(symbols), self.selenium.page_source)
        self.assertIn(escape(symbols + '2'), self.selenium.page_source)

        # Click in the Actions navigation menu
        self.go_to_actions()

        # Edit the action-in
        self.open_action_edit('action in')

        # Go to questions
        self.select_questions_tab()

        # Set the right columns to process
        self.click_dropdown_option(
            "//div[@id='column-selector']",
            '!#$%&()*+,-./\\:;<=>?@[]^_`{|}~2'
        )
        self.wait_for_datatable('column-selected-table_previous')
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'column-selected-table_previous')
            )
        )

        # Set some parameters
        self.select_parameters_tab()
        self.click_dropdown_option(
            "//div[@id='select-key-column-name']", 'sid')
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        self.select_parameters_tab()
        self.click_dropdown_option("//div[@id='select-key-column-name']",
                                   'email')
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        # Save action-in
        self.select_questions_tab()
        self.selenium.find_element_by_link_text('Done').click()
        self.wait_for_datatable('action-table_previous')

        # Click in the RUN link of the action in
        element = self.search_action('action in')
        element.find_element_by_link_text("Run").click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'actioninrun-data_previous'))
        )

        # Enter data using the RUN menu. Select one entry to populate
        self.selenium.find_element_by_link_text("*****@*****.**").click()
        self.wait_for_page(element_id='action-row-datainput')
        self.selenium.find_element_by_id("id____ontask___select_1").click()
        self.selenium.find_element_by_id("id____ontask___select_1").clear()
        self.selenium.find_element_by_id("id____ontask___select_1").send_keys(
            "17")
        self.selenium.find_element_by_id("id____ontask___select_2").click()
        self.selenium.find_element_by_id("id____ontask___select_2").clear()
        self.selenium.find_element_by_id("id____ontask___select_2").send_keys(
            "Carmelo Coton2")
        self.selenium.find_element_by_id("id____ontask___select_3").click()
        self.selenium.find_element_by_id("id____ontask___select_3").clear()
        self.selenium.find_element_by_id("id____ontask___select_3").send_keys(
            "xxx"
        )

        # Submit the data for one entry
        self.selenium.find_element_by_xpath(
            "//div[@id='action-row-datainput']//form//button").click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'actioninrun-data_previous'))
        )

        # Go Back to the action table
        self.go_to_actions()

        # Edit the action out
        self.open_action_edit('action_out')

        # Click in the editor
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.CLASS_NAME, 'note-editable')
            )
        )
        self.selenium.find_element_by_class_name('note-editable').click()

        # Insert attribute
        self.click_dropdown_option("//div[@id='attribute-selector']",
                                   symbols + '3')

        # Insert column name
        self.click_dropdown_option("//div[@id='column-selector']", symbols)

        # Insert second column name
        self.click_dropdown_option("//div[@id='column-selector']",
                                   symbols + '2')

        # Create new condition
        self.create_condition(symbols + "4",
                              '',
                              [(symbols, "begins with", "C")])

        # Create the filter
        self.create_filter('', [(symbols + "2", "doesn't begin with", "x")])

        # Click the preview button
        self.select_text_tab()
        self.selenium.find_element_by_class_name('js-action-preview').click()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.CLASS_NAME, 'js-action-preview-nxt'))
        )

        # Certain name should be in the page now.
        self.assertIn('Carmelo Coton', self.selenium.page_source)

        # Click in the "Close" button
        self.selenium.find_element_by_xpath(
            "//div[@id='modal-item']/div/div/div/div[2]/button[2]").click()

        assert check_wf_df(Workflow.objects.get(name='sss'))

        # End of session
        self.logout()
コード例 #44
0
ファイル: test_views.py プロジェクト: deborahlow97/ontask_b
    def test_02_second_plugin(self):
        # Login
        self.login('*****@*****.**')

        # GO TO THE WORKFLOW PAGE
        self.access_workflow_from_home_page('Plugin test')

        # Open the transform page
        self.go_to_transform()

        # Click in the second plugin
        element = self.search_table_row_by_string('transform-table',
                                                  1,
                                                  'Test Plugin 2 Name')
        element.find_element_by_link_text('Test Plugin 2 Name').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.NAME, 'csrfmiddlewaretoken'))
        )

        # Provide the execution data (input columns and merge key
        self.selenium.find_element_by_id(
            "id____ontask___upload_input_0"
        ).click()
        Select(self.selenium.find_element_by_id(
            "id____ontask___upload_input_0"
        )).select_by_visible_text('A1')
        self.selenium.find_element_by_id(
            "id____ontask___upload_input_1"
        ).click()
        Select(self.selenium.find_element_by_id(
            "id____ontask___upload_input_1"
        )).select_by_visible_text('A2')
        # merge key
        self.select_plugin_output_tab()
        self.selenium.find_element_by_id("id_merge_key").click()
        Select(self.selenium.find_element_by_id(
            "id_merge_key"
        )).select_by_visible_text("email")
        # Submit the execution
        self.selenium.find_element_by_name("Submit").click()

        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Plugin scheduled for execution')
        )

        # There should be a message on that page
        self.assertTrue(
            self.selenium.find_element_by_xpath(
                "//div[@id='plugin-run-done']/div/a"
            ).text.startswith(
                'You may check the status in log number'
            )
        )

        # Assert the content of the dataframe
        wflow = Workflow.objects.get(name='Plugin test')
        df = load_table(wflow.get_data_frame_table_name())
        self.assertTrue('RESULT 3' in set(df.columns))
        self.assertTrue('RESULT 4' in set(df.columns))
        self.assertTrue(df['RESULT 3'].equals(df['A1'] + df['A2']))
        self.assertTrue(df['RESULT 4'].equals(df['A1'] - df['A2']))

        assert check_wf_df(Workflow.objects.get(name='Plugin test'))

        # End of session
        self.logout()
コード例 #45
0
    def select_dropdown_value(self, locator, value):
        driver = self.app.driver
        s1 = Select(driver.find_element_by_name(locator))

        for opt in s1.options:
            s1.select_by_visible_text(value)
コード例 #46
0
ファイル: test_views.py プロジェクト: deborahlow97/ontask_b
    def test_01_nan_manipulation(self):
        # Login
        self.login('*****@*****.**')

        self.create_new_workflow('NaN')

        # Go to CSV Upload/Merge
        self.selenium.find_element_by_xpath(
            "//table[@id='dataops-table']//a[normalize-space()='CSV']").click()
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, "//form")
            )
        )

        # Select file and upload
        self.selenium.find_element_by_id("id_data_file").send_keys(
            os.path.join(settings.BASE_DIR(),
                         'dataops',
                         'fixtures',
                         'test_df_merge_update_df1.csv')
        )
        self.selenium.find_element_by_name("Submit").click()
        self.wait_for_page()

        # Submit
        self.selenium.find_element_by_xpath(
            "(//button[@name='Submit'])[2]"
        ).click()
        self.wait_for_datatable('table-data_previous')

        # Select again the upload/merge function
        self.go_to_csv_upload_merge_step_1()

        # Select the second file and submit
        self.selenium.find_element_by_id("id_data_file").send_keys(
            os.path.join(settings.BASE_DIR(),
                         'dataops',
                         'fixtures',
                         'test_df_merge_update_df2.csv')
        )
        self.selenium.find_element_by_name("Submit").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.XPATH, "//body/div/h1"),
                                             'Select Columns')
        )

        # Select all the columns for upload
        self.selenium.find_element_by_name("Submit").click()
        # Wait for the upload/merge
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Select Keys and Merge Option')
        )

        # Choose the default options for the merge (key and outer)
        # Select the merger function type
        select = Select(self.selenium.find_element_by_id('id_how_merge'))
        select.select_by_value('outer')
        self.selenium.find_element_by_name("Submit").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//body/div/h1"),
                'Review and confirm')
        )

        # Check the merge summary and proceed
        self.selenium.find_element_by_name("Submit").click()
        # Wait for the upload/merge to finish
        self.wait_for_datatable('table-data_previous')

        # Go to the actions page
        self.go_to_actions()

        # Create a new action
        self.create_new_personalized_text_action("action out", '')

        # Create three conditions
        self.select_condition_tab()
        self.create_condition("bool1 cond", '', [('bool1', None, True)])
        self.create_condition("bool 2 cond", '', [('bool2', None, True)])
        self.create_condition('bool3 cond', '', [('bool3', None, True)])

        # insert the action text
        self.select_text_tab()
        self.selenium.execute_script(
            """$('#id_text_content').summernote('editor.insertText', 
            "{0}");""".format(self.action_text)
        )

        # Click in the preview and circle around the 12 rows
        self.open_browse_preview(11)

        assert check_wf_df(Workflow.objects.get(name='wflow1'))

        # End of session
        self.logout()
コード例 #47
0
 def select_dropdown_value(self, field_name, text):
     wd = self.app.wd
     if text is not None:
         wd.find_element_by_name(field_name).click()
         Select(wd.find_element_by_name(field_name)).select_by_visible_text(
             text)
コード例 #48
0
 def click_host_group(self):
     Select(self.find_element(
         *self.host_group_loc)).select_by_visible_text("DELL")
コード例 #49
0
# 访问百度
url = 'http://www.baidu.com'
driver.get(url)

# 定位到设置元素并且点击
el = driver.find_element_by_link_text('设置')
el.click()

# 定位搜索设置,并且点击
el_set = driver.find_element_by_css_selector('.setpref')
el_set.click()

# 定位到下拉框元素
el_select = driver.find_element_by_id('nr')
# 创建下拉框对象
selobj = Select(el_select)

# 通过选项的索引进行设置
# selobj.select_by_index(0)
# time.sleep(1)
# selobj.select_by_index(1)
# time.sleep(1)
# selobj.select_by_index(2)

# 通过value进行设置
# selobj.select_by_value('50')
# time.sleep(1)
# selobj.select_by_value('20')
# time.sleep(1)
# selobj.select_by_value('10')
# time.sleep(1)
コード例 #50
0
def drop_down_multi_select():
    url_dropdown = "https://www.seleniumeasy.com/test/basic-select-dropdown-demo.html"
    driver.get(url_dropdown)
    ddown_list = driver.find_element_by_id("multi-select")  # Select element with '<select>' tag
    selection = Select(ddown_list)

    # Multi select drop down enables you to select multi options
    selection.select_by_value("New York")
    selection.select_by_visible_text("Ohio")
    print("selection.all_selected_options :")
    for element in selection.all_selected_options:
        print(element.text)  # this will return all selected options (new york, ohio)
    print("Delesecting by index: ")
    selection.deselect_by_index(4)

    selection.select_by_index(5)
    selection.select_by_index(7)
    print("Deselecting_all : ")
    selection.deselect_all()
コード例 #51
0
 def selectCheckWorkStatus(self, checkWork_status):
     '''选择打卡状态'''
     return Select(
         self.checkWorkStatus()).select_by_visible_text(checkWork_status)
コード例 #52
0
 def select_random(cls, selecter):  # selecter是传递的下拉框元素
     from selenium.webdriver.support.select import Select
     seleter_length = len(Select(selecter).options)
     import random
     random_index = random.randint(0, seleter_length - 1)
     Select(selecter).select_by_index(random_index)
コード例 #53
0
    def test_ConfigGuide(self):
        u'''配置向导配置无线'''
        cpumodel = getCPUmodel()
        guide = ConfigGuidepage(self.driver, self.url)
        guide.click_configGuide()
        time.sleep(0.5)
        guide.click_next()
        time.sleep(1)
        # guide.click_next() #不修改接入方式
        # time.sleep(1)
        try:
            self.driver.implicitly_wait(2)
            guide.click_next()
        except NoSuchElementException:
            CapPic(self.driver)
            logger.info(u'配置向导中,不支持wifi参数配置')
            raise Exception('配置向导中,不支持wifi参数配置')
        else:
            time.sleep(1)
        guide.input_ssid('test3_2.4')
        guide.input_passwd('12345678')
        channel = guide.selelement_byName(guide.channel)
        Select(channel).select_by_value('7')
        wrlessMode = guide.selelement_byName(guide.wrlessMode)
        chanWidth = guide.selelement_byName(guide.chanWidth)
        if cpumodel == 'MTK':
            Select(wrlessMode).select_by_value('6')  #mtk 11n
            Select(chanWidth).select_by_value('2')  #mtk为40M
        elif cpumodel == 'Qualcomm':
            Select(wrlessMode).select_by_value('1')  #高通 11n
            Select(chanWidth).select_by_value('3')  #高通 40M
        if support5 != '--':
            try:
                guide.find_ssid_5g()
            except NoSuchElementException:
                CapPic(self.driver)
                logger.info(u'不支持5G,与参数表不相符')
                raise Exception('不支持5G,与参数表不相符')
            guide.input_ssid_5g('test3_5')
            guide.input_passwd_5g('12345678')
            channel_5g = guide.selelement_byName(guide.channel_5g)
            Select(channel_5g).select_by_value('36')
            wrlessMode_5g = guide.selelement_byName(guide.wrlessMode_5g)
            chanWidth_5g = guide.selelement_byName(guide.chanWidth_5g)
            if cpumodel == 'MTK':
                Select(wrlessMode_5g).select_by_value('15')  # mtk 11vht AC/AN
                Select(chanWidth_5g).select_by_value('2')  # mtk为40M
            elif cpumodel == 'Qualcomm':
                Select(wrlessMode_5g).select_by_value('5')  # 高通 11ac
                Select(chanWidth_5g).select_by_value('3')  # 高通 HT40
        guide.click_okey()
        time.sleep(35)

        self.driver.implicitly_wait(10)
        basicConfig = BasicConfigPage(self.driver, self.url)
        basicConfig.click_wifiConfig()
        time.sleep(0.5)
        basicConfig.click_BasicConfig()
        time.sleep(1)
        lsit_ssid1 = basicConfig.getText_byXpath(basicConfig.list_ssid1)
        self.assertEqual(lsit_ssid1, 'test3_2.4', msg='2.4G SSID保存异常')
        lsit_Mode1 = basicConfig.getText_byXpath(basicConfig.list_Mode1)
        self.assertEqual(lsit_Mode1, 'WPA-PSK/WPA2-PSK', msg='2.4G密码加密模式异常')
        list_wifipwd1 = basicConfig.getAttribute_byXpath(
            basicConfig.list_wifipwd1, 'data-local')
        self.assertEqual(list_wifipwd1, '12345678', msg='2.4G密码保存异常')
        tn = telnetlib.Telnet(host=host, port=port, timeout=10)  #telnet验证
        tn.set_debuglevel(5)
        tn.read_until(b'login:'******'Password:'******'#')
        if cpumodel == "MTK":
            tn.write(
                b'cat /etc/Wireless/RT2860/RT2860.dat | grep -E "SSID1|WPAPSK1"'
                + b'\n')
        elif cpumodel == "Qualcomm":
            tn.write(
                b'cat /etc/Wireless/wifi0/qca_ath0.dat | grep -E "ssid|key"' +
                b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 判断
        if cpumodel == "MTK":
            if "SSID1=test3_2.4" in result:
                print('2.4G SSID配置正常')
            else:
                raise Exception('2.4G SSID配置异常')
            if "WPAPSK1=12345678" in result:
                print('2.4G 密码配置正常')
            else:
                raise Exception('2.4G 密码配置异常')
        elif cpumodel == "Qualcomm":
            if "ssid=test3_2.4" in result:
                print('2.4G SSID配置正常')
            else:
                raise Exception('2.4G SSID配置异常')
            if "key=12345678" in result:
                print('2.4G 密码配置正常')
            else:
                raise Exception('2.4G 密码配置异常')
        tn.close()  # tn.write('exit\n')
        if support5 != '--':
            time.sleep(5)
            try:
                lsit_ssid2 = basicConfig.getText_byXpath(
                    basicConfig.list_ssid2)
            except NoSuchElementException:
                CapPic(self.driver)
                logger.info(u'不支持5G,与参数表不相符')
                raise Exception('不支持5G,与参数表不相符')
            self.assertEqual(lsit_ssid2, 'test3_5', msg='5G SSID保存异常')
            lsit_Mode2 = basicConfig.getText_byXpath(basicConfig.list_Mode2)
            self.assertEqual(lsit_Mode2, 'WPA-PSK/WPA2-PSK', msg='5G密码加密模式异常')
            list_wifipwd2 = basicConfig.getAttribute_byXpath(
                basicConfig.list_wifipwd2, 'data-local')
            self.assertEqual(list_wifipwd2, '12345678', msg='5G密码保存异常')
            tn = telnetlib.Telnet(host=host, port=port, timeout=10)  # telnet验证
            tn.set_debuglevel(5)
            tn.read_until(b'login:'******'Password:'******'#')
            if cpumodel == "MTK":
                tn.write(
                    b'cat /etc/Wireless/iNIC/iNIC_ap.dat  | grep -E "SSID1|WPAPSK1"'
                    + b'\n')
            elif cpumodel == "Qualcomm":
                tn.write(
                    b'cat /etc/Wireless/wifi1/qca_ath1.dat | grep -E "ssid|key"'
                    + b'\n')
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            print('result:', result)
            # 判断
            if cpumodel == "MTK":
                if "SSID1=test3_5" in result:
                    print('5G SSID配置正常')
                else:
                    raise Exception('5G SSID配置异常')
                if "WPAPSK1=12345678" in result:
                    print('5G 密码配置正常')
                else:
                    raise Exception('5G 密码配置异常')
            elif cpumodel == "Qualcomm":
                if "ssid=test3_5" in result:
                    print('5G SSID配置正常')
                else:
                    raise Exception('5G SSID配置异常')
                if "key=12345678" in result:
                    print('5G 密码配置正常')
                else:
                    raise Exception('5G 密码配置异常')
            tn.close()  # tn.write('exit\n')

        rfConfig = RFConfigPage(self.driver, self.url)
        rfConfig.click_RFConfig()
        time.sleep(1)
        if support5 != '--':
            channel2_7 = rfConfig.getAttribute_byXpath(rfConfig.channel2_7,
                                                       'selected')
            if cpumodel == "MTK":
                wrlessMode2_11n = rfConfig.getAttribute_byXpath(
                    rfConfig.wrlessMode2_11nM, 'selected')
                chanWidth2_40 = rfConfig.getAttribute_byXpath(
                    rfConfig.chanWidth2_40M, 'selected')
            elif cpumodel == "Qualcomm":
                wrlessMode2_11n = rfConfig.getAttribute_byXpath(
                    rfConfig.wrlessMode2_11nQ, 'selected')
                chanWidth2_40 = rfConfig.getAttribute_byXpath(
                    rfConfig.chanWidth2_40Q, 'selected')
        else:
            channel2_7 = rfConfig.getAttribute_byXpath(rfConfig.channel2_71,
                                                       'selected')
            if cpumodel == "MTK":
                wrlessMode2_11n = rfConfig.getAttribute_byXpath(
                    rfConfig.wrlessMode2_11nM1, 'selected')
                chanWidth2_40 = rfConfig.getAttribute_byXpath(
                    rfConfig.chanWidth2_40M1, 'selected')
        self.assertEqual(channel2_7, 'true', msg='2.4G信道不为7')

        self.assertEqual(wrlessMode2_11n, 'true', msg='2.4G模式不为11n')
        self.assertEqual(chanWidth2_40, 'true', msg='2.4G频宽不为40M')
        tn = telnetlib.Telnet(host=host, port=port, timeout=10)  # telnet验证
        tn.set_debuglevel(5)
        tn.read_until(b'login:'******'Password:'******'#')
        if cpumodel == "MTK":
            tn.write(
                b'cat /etc/Wireless/RT2860/RT2860.dat | grep -E "WirelessMode|Channel|HT_BW|HT_BSSCoexistence"'
                + b'\n')
        elif cpumodel == "Qualcomm":
            tn.write(
                b'cat /etc/Wireless/wifi0/qca_ath0.dat | grep -E "hwmode|channel|htmode"'
                + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        print('result:', result)
        # 判断
        if cpumodel == "MTK":
            if "WirelessMode=6" in result:  #11n
                print('2.4G模式配置正常')
            else:
                raise Exception('2.4G模式配置异常')
            if "Channel=7" in result:
                print('2.4G信道配置正常')
            else:
                raise Exception('2.4G信道配置异常')
            if "HT_BW=1" and "HT_BSSCoexistence=0" in result:  #40M
                print('2.4G频宽配置正常')
            else:
                raise Exception('2.4G频宽配置异常')
        elif cpumodel == "Qualcomm":
            if "hwmode=11n" in result:  #11n
                print('2.4G模式配置正常')
            else:
                raise Exception('2.4G模式配置异常')
            if "channel=7" in result:
                print('2.4G信道配置正常')
            else:
                raise Exception('2.4G信道配置异常')
            if "htmode=HT40" in result:  #40M
                print('2.4G频宽配置正常')
            else:
                raise Exception('2.4G频宽配置异常')
        tn.close()  # tn.write('exit\n')
        if support5 != '--':
            try:
                if cpumodel == "MTK":
                    wrlessMode5_15 = rfConfig.getAttribute_byXpath(
                        rfConfig.wrlessMode5_15M, 'selected')
                elif cpumodel == "Qualcomm":
                    wrlessMode5_15 = rfConfig.getAttribute_byXpath(
                        rfConfig.wrlessMode5_15Q, 'selected')
            except NoSuchElementException:
                CapPic(self.driver)
                logger.info(u'不支持5G,与参数表不相符')
                raise Exception('不支持5G,与参数表不相符')
            self.assertEqual(wrlessMode5_15, 'true', msg='5G模式不为 11vht AC/AN')
            if languageA == 'English':
                channel5_36 = rfConfig.getAttribute_byXpath(
                    rfConfig.channel5_36_2, 'selected')  #英文版本多一个国家码
            else:
                channel5_36 = rfConfig.getAttribute_byXpath(
                    rfConfig.channel5_36, 'selected')
            self.assertEqual(channel5_36, 'true', msg='5G信道不为36')
            if cpumodel == "MTK":
                if languageA == 'English':
                    chanWidth5_40 = rfConfig.getAttribute_byXpath(
                        rfConfig.chanWidth5_40M_2, 'selected')
                else:
                    chanWidth5_40 = rfConfig.getAttribute_byXpath(
                        rfConfig.chanWidth5_40M, 'selected')
            elif cpumodel == "Qualcomm":
                if languageA == 'English':
                    chanWidth5_40 = rfConfig.getAttribute_byXpath(
                        rfConfig.chanWidth5_40Q_2, 'selected')
                else:
                    chanWidth5_40 = rfConfig.getAttribute_byXpath(
                        rfConfig.chanWidth5_40Q, 'selected')
            self.assertEqual(chanWidth5_40, 'true', msg='5G频宽不为40M')
            tn = telnetlib.Telnet(host=host, port=port, timeout=10)  # telnet验证
            tn.set_debuglevel(5)
            tn.read_until(b'login:'******'Password:'******'#')
            if cpumodel == "MTK":
                tn.write(
                    b'cat /etc/Wireless/iNIC/iNIC_ap.dat | grep -E "WirelessMode|Channel|HT_BW|HT_BSSCoexistence"'
                    + b'\n')  # 无线隔离
            elif cpumodel == "Qualcomm":
                tn.write(
                    b'cat /etc/Wireless/wifi1/qca_ath1.dat | grep -E "hwmode|channel|htmode"'
                    + b'\n')
            # 输出结果,判断
            time.sleep(1)
            result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
            print('-------------------输出结果------------------------')
            # 命令执行结果
            print('result:', result)
            # 判断
            if cpumodel == "MTK":
                if "WirelessMode=15" in result:  # mtk 11vht AC/AN
                    print('5G模式配置正常')
                else:
                    raise Exception('5G模式配置异常')
                if "Channel=36" in result:
                    print('5G信道配置正常')
                else:
                    raise Exception('5G信道配置异常')
                if "HT_BW=1" and "HT_BSSCoexistence=0" in result:  # 40M
                    print('5G频宽配置正常')
                else:
                    raise Exception('5G频宽配置异常')
            elif cpumodel == "Qualcomm":
                if "hwmode=11ac" in result:  # mtk 11vht AC/AN
                    print('5G模式配置正常')
                else:
                    raise Exception('5G模式配置异常')
                if "channel=36" in result:
                    print('5G信道配置正常')
                else:
                    raise Exception('5G信道配置异常')
                if "htmode=HT40" in result:  # 40M
                    print('5G频宽配置正常')
                else:
                    raise Exception('5G频宽配置异常')
            tn.close()  # tn.write('exit\n')

        self.driver.quit()
        logger.info('test_ConfigGuide passed')
コード例 #54
0
 def select_combobox_value(self, combobox, value_to_find):
     sel = Select(combobox)
     sel.select_by_visible_text(value_to_find)
コード例 #55
0
)
print("select button : ", selectButton)
selectButton.click()

selectButton2 = driver.find_element(
    By.ID,
    'ctl00_ContentPlaceHolderMain_VariableSelector1_VariableSelector1_VariableSelectorValueSelectRepeater_ctl02_VariableValueSelect_VariableValueSelect_SelectAllButton'
)
print("select button 2: ", selectButton2)
selectButton2.click()

fileTypes = driver.find_element(
    By.ID,
    "ctl00_ContentPlaceHolderMain_VariableSelector1_VariableSelector1_OutputFormats_OutputFormats_OutputFormatDropDownList"
)
fileValues = Select(fileTypes)
fileList = fileValues.options
print(len(fileList))

for file in fileList:
    if file.text == 'Phân tách bới dấu chấm phẩy kèm tiêu đề':
        file.click()
        break

submitButton = driver.find_element(
    By.ID,
    "ctl00_ContentPlaceHolderMain_VariableSelector1_VariableSelector1_ButtonViewTable"
)
submitButton.click()

time.sleep(15)
コード例 #56
0
ファイル: SEM.py プロジェクト: chetandg123/cQube_Testing
 def test_select_district_block_cluster(self):
     time.sleep(5)
     select_district = Select(
         self.driver.find_element_by_xpath(Data.select_sem_district))
     select_block = Select(
         self.driver.find_element_by_xpath(Data.select_sem_blocks))
     select_cluster = Select(
         self.driver.find_element_by_xpath(Data.select_sem_clusters))
     time.sleep(5)
     for x in select_district.options[1:]:
         select_district.select_by_visible_text(x.text)
         list = self.driver.find_elements_by_class_name(Data.dots)
         elem = self.driver.find_element_by_xpath(Data.No_sem_schools).text
         res = re.sub("\D", "", elem)
         district = set()
         if int(len(list) - 1) != int(res):
             district.add((x.text, 'Count Mismatch'))
         time.sleep(3)
         for y in select_block.options[1:]:
             select_block.select_by_visible_text(y.text)
             list = self.driver.find_elements_by_class_name(Data.dots)
             elem = self.driver.find_element_by_xpath(
                 Data.No_sem_schools).text
             res = re.sub("\D", "", elem)
             block = set()
             if int(len(list) - 1) != int(res):
                 block.add((x.text, y.text, 'Count Mismatch'))
             time.sleep(3)
             c = 0
             for z in select_cluster.options[1:]:
                 select_cluster.select_by_visible_text(z.text)
                 # print(x.text, " ", y.text, " ", z.text)
                 time.sleep(3)
                 list = self.driver.find_elements_by_class_name(Data.dots)
                 elem = self.driver.find_element_by_xpath(
                     Data.No_sem_schools).text
                 res = re.sub("\D", "", elem)
                 cluster = set()
                 if int(len(list) - 1) != int(res):
                     cluster.add((x.text, y.text, z.text, 'Count Mismatch'))
                 report = pd.DataFrame([district, block, cluster])
                 with open('sem-report.html', 'w') as fd:
                     fd.write(report.to_html())
コード例 #57
0
from selenium import webdriver
from selenium.webdriver.support.select import Select

driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")

# driver = webdriver.Firefox(executable_path="F:\\Internship\\geckodriver.exe")

driver.get("https://www.rahulshettyacademy.com/angularpractice/")
#driver.find_element_by_name("name").send_keys("Madhurima")
driver.find_element_by_css_selector("input[name='name']").send_keys("Sana")

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

#select class provides the methods to handle the option is dropdown

dropdown = Select(driver.find_element_by_id("exampleFormControlSelect1"))
dropdown.select_by_visible_text("Female")
dropdown.select_by_index(0)
# dropdown.select_by_value("M")

driver.find_element_by_id("exampleCheck1").click()

driver.find_element_by_xpath("//input[@type='submit']").click()

# print(driver.find_element_by_class_name("alert-success").text)

message = driver.find_element_by_class_name("alert-success").text

assert "success" in message
# assert "success" in  message
コード例 #58
0
from winsound import Beep#提示声音模块
path = r"C:\Users\admin\Downloads\chromedriver.exe"#谷歌控住器路径
url = "https://kyfw.12306.cn/otn/leftTicket/init?"#12306网址
browser = webdriver.Chrome(path)#用谷歌打开浏览器
time.sleep(5)#睡5秒
browser.get(url)#用谷歌请求12306网址
start_city = browser.find_element_by_id("fromStationText")#用谷歌请求开始位置的id
start_city.click()#筛选
start_city.clear()#清
start_city.send_keys("北京\n")#输入自己现在的地方
start_city = browser.find_element_by_id("toStationText")#用谷歌输入目的地的id
start_city.click()#筛选
start_city.clear()#清除
start_city.send_keys("上海\n")#输入自己目的地

choice_time = Select(browser.find_element_by_id("cc_start_time"))#这个是获取下拉框当前时间
choice_time.select_by_visible_text("00:00--24:00")#这是输入时间
data = browser.find_element_by_css_selector("#date_range li:nth-child(5)")#时间
data.click()#筛选

time.sleep(3)

favorite = ["G9","G129","G137","G145","G11","G153"]#车的种类


xpath ='//tbody[@id="queryLeftTable"]//td[4][@class]/../td[1]//a'#有票的车信息
train_list = browser.find_elements_by_xpath(xpath)#提取车票信息

for train in train_list:
    train_num = train.text
    if train_num in favorite:
コード例 #59
0
    def test_local_mnist_manual(self):
        driver1 = self.driver1

        myurl = Myurl(self.driver1)
        myurl.access_url()
        driver1.implicitly_wait(10)
        print("This is Title name :", driver1.title)

        # ScreenShot Relative Path
        ss_path = '/Rvirtus/'
        # Creating object of screenshot utility
        ss = SS(driver1)

        # ------Memory and core Percentages ----------
        percentages = Memory_and_Core_Percentages()
        gpuper0 = percentages.gpuper0
        gpuper1 = percentages.gpuper1
        gpuper2 = percentages.gpuper2
        gpuper3 = percentages.gpuper3
        gpuper4 = percentages.gpuper4
        gpuper5 = percentages.gpuper5
        gpuper6 = percentages.gpuper6
        gpuper7 = percentages.gpuper7
        coreper0 = percentages.coreper0
        coreper1 = percentages.coreper1
        coreper2 = percentages.coreper2
        coreper3 = percentages.coreper3
        coreper4 = percentages.coreper4
        coreper5 = percentages.coreper5
        coreper6 = percentages.coreper6
        coreper7 = percentages.coreper7
        # ------- Login Details ------------
        user = LoginUsers()
        Admin = user.user1_name
        Pwd = user.user1_password
        expadmin = user.user1_expadmin
        exppass = user.user1_exppass
        # ------ local path ------------
        paths = Paths()
        locGVpath = paths.Local_GVirtus_path
        Backendip = paths.Backend_ip

        admin_login = AdminLogin(driver1)
        admin_login.set_login_uname(Admin)
        admin_login.set_login_upass(Pwd)
        sleep(3)
        admin_login.submit_login(Admin, Pwd)
        sleep(5)
        if Admin == expadmin and Pwd == exppass:
            print("Login successful")
        else:
            assert print("Invalid credentials")

        print("************ Mnist Manual *****************")
        # --------Frame work--------------
        f = self.driver1.find_element_by_xpath(
            "//img[@src='/images/tenserflow.png']")
        f.click()
        print("Selected Tensorflow")
        sleep(2)
        # --------if you have compound class name you should write like this-----------
        inception = self.driver1.find_element_by_xpath(
            "//*[@class='card-body text-center font-weight-normal btnNext']")
        inception.click()
        sleep(1)
        assert isinstance(inception.text, object)
        print("Your Selected ", str(inception.text))
        #print("Selected Inception")

        # -----------local folder---------------
        local = self.driver1.find_element(By.ID, 'r100')
        local.click()
        sleep(1)
        localpath = self.driver1.find_element(By.ID, 'local_dir_path')
        localpath.send_keys(locGVpath)

        sleep(2)
        # ----------GPU Manual --------
        gpu = self.driver1.find_element(By.ID, 'r4')
        gpu.click()
        sleep(2)

        print("Your selected Manual")
        manual = self.driver1.find_element_by_id("r102")
        manual.click()
        sleep(1)
        # ------ gpu percentage -----------
        memory0 = self.driver1.find_element(By.ID, 'gpupercent0')
        memory0.send_keys(gpuper0)
        sleep(1)
        memory1 = self.driver1.find_element(By.ID, 'gpupercent1')
        memory1.send_keys(gpuper1)
        sleep(1)
        memory2 = self.driver1.find_element(By.ID, 'gpupercent2')
        memory2.send_keys(gpuper2)
        sleep(1)
        memory3 = self.driver1.find_element(By.ID, 'gpupercent3')
        memory3.send_keys(gpuper3)
        sleep(1)
        memory4 = self.driver1.find_element(By.ID, 'gpupercent4')
        memory4.send_keys(gpuper4)
        sleep(1)
        memory5 = self.driver1.find_element(By.ID, 'gpupercent5')
        memory5.send_keys(gpuper5)
        sleep(1)
        memory6 = self.driver1.find_element(By.ID, 'gpupercent6')
        memory6.send_keys(gpuper6)
        sleep(1)
        memory7 = self.driver1.find_element(By.ID, 'gpupercent7')
        memory7.send_keys(gpuper7)
        print("gpu percentages : ", gpuper0, gpuper1, gpuper2, gpuper3,
              gpuper4, gpuper5, gpuper6, gpuper7)
        # --------core percentage -----------
        sleep(1)
        gpuvalue0 = self.driver1.find_element(By.ID, 'gpuvalue0')
        gpuvalue0.send_keys(coreper0)
        sleep(1)
        gpuvalue1 = self.driver1.find_element(By.ID, 'gpuvalue1')
        gpuvalue1.send_keys(coreper1)
        sleep(1)
        gpuvalue2 = self.driver1.find_element(By.ID, 'gpuvalue2')
        gpuvalue2.send_keys(coreper2)
        sleep(1)
        gpuvalue3 = self.driver1.find_element(By.ID, 'gpuvalue3')
        gpuvalue3.send_keys(coreper3)
        sleep(1)
        gpuvalue4 = self.driver1.find_element(By.ID, 'gpuvalue4')
        gpuvalue4.send_keys(coreper4)
        sleep(1)
        gpuvalue5 = self.driver1.find_element(By.ID, 'gpuvalue5')
        gpuvalue5.send_keys(coreper5)
        sleep(1)
        gpuvalue6 = self.driver1.find_element(By.ID, 'gpuvalue6')
        gpuvalue6.send_keys(coreper6)
        sleep(1)
        gpuvalue7 = self.driver1.find_element(By.ID, 'gpuvalue7')
        gpuvalue7.send_keys(coreper7)
        print("core percentages : ", coreper0, coreper1, coreper2, coreper3,
              coreper4, coreper5, coreper6, coreper7)
        sleep(2)

        # ------Screenshot-1-----------
        ss.ScreenShot(ss_path + "test_02_local_mnist_manual-SetupsScreen.png")
        # -------------------- setup btn -----------------
        setupbtn = self.driver1.find_element(By.ID, 'setupbtn')
        setupbtn.click()
        sleep(25)

        # -------Datsets & Training  ----------------
        traindir = self.driver1.find_element(By.ID, 'traindirectory')
        trdirectory = Select(traindir)
        trdirectory.select_by_visible_text("Mnist_classification")
        sleep(2)

        trinfile = self.driver1.find_element(By.ID, 'file_name')
        trfile = Select(trinfile)
        trfile.select_by_visible_text("mnist_gpu.py")
        sleep(2)
        # --------- Train --------------------
        train = self.driver1.find_element_by_xpath("//a[@href='#train']")
        train.click()
        sleep(2)
        Train = self.driver1.find_element(By.ID, 'train_id')
        Train.click()
        sleep(30)
        gpuTime = driver1.find_elements_by_id("gputime")
        for GpuUsage in gpuTime:
            assert isinstance(GpuUsage.text, object)
            print("Gpu Usage : ", str(GpuUsage.text))
        sleep(60)

        # --------Elapsed Time -------------------
        myElem = self.driver1.find_element_by_id("elapsedTime")
        myElem.click()
        sleep(1)
        # ------Screenshot-2-----------
        ss.ScreenShot(ss_path + "test_02_local_mnist_manual-ElapsedTime.png")
        sleep(2)
        assert isinstance(myElem.text, object)
        print("Mnist Manual -", str(myElem.text))
        for logs in driver1.get_log('browser'):
            print(logs)
        try:
            pass

            #log = self.get_browser_console_log()
            #log = self.driver1.get_log(browser)
            #print("Console Log: ",log)
        except Exception as e:
            print("Exception Occurred :" + str(e))
        # ---------Logout ----------------
        self.driver1.find_element_by_id("navbarDropdownMenuLink").click()
        logout = self.driver1.find_element_by_class_name("dropdown-item")
        logout.click()
        sleep(5)
        for Logedout in self.driver1.find_elements_by_xpath(
                "//*[@class='alert alert-success']"):
            assert isinstance(Logedout.text, object)
            print(str(Logedout.text))
コード例 #60
0
 def select_in_drop_down(self, field_name, text):
     wd = self.app.wd
     if text is not None:
         Select(wd.find_element_by_name(field_name)).select_by_visible_text(
             text)