コード例 #1
0
ファイル: incall.py プロジェクト: digideskio/xivo-acceptance
def type_incall_destination(destination_type, destination_name):
    type_select = Select(world.browser.find_element_by_id('it-dialaction-answer-actiontype'))
    type_select.select_by_visible_text(destination_type)
    destination_select = Select(world.browser.find_element_by_id(DESTINATION_ELEMENT_MAP[destination_type]))
    for option in destination_select.options:
        if destination_name in option.text:
            destination_select.select_by_visible_text(option.text)
コード例 #2
0
ファイル: page_helpers.py プロジェクト: Gimpneek/cv_gen
def select_multi(context, key, data):
    input_selector = (By.NAME, key)
    input_el = context.browser.find_element(*input_selector)
    select = Select(input_el)
    for item in data:
        select.select_by_visible_text(item)
    return [opt.text for opt in select.all_selected_options]
コード例 #3
0
ファイル: tests.py プロジェクト: romali/django-multiseek
    def test_load_form(self):
        fld = make_field(
            self.registry.fields[2],
            self.registry.fields[2].ops[1],
            json.dumps([2000, 2010]))
        SearchForm.objects.create(
            name="lol",
            owner=User.objects.create(username='******', password='******'),
            public=True,
            data=json.dumps({"form_data": [None, fld]}))
        self.page.load_form_by_name('lol')

        field = self.page.extract_field_data(
            self.page.find_element_by_jquery("#field-0"))

        self.assertEquals(
            field['selected'], unicode(self.registry.fields[2].label))
        self.assertEquals(field['value'][0], 2000)
        self.assertEquals(field['value'][1], 2010)

        # Przetestuj, czy po ANULOWANIU select wróci do pierwotnej wartości
        select = Select(
            self.page.find_element_by_jquery("#formsSelector"))
        select.select_by_visible_text('lol')
        self.page.switch_to_alert().dismiss()

        self.assertEquals(
            self.page.find_element_by_jquery("#formsSelector").val(), "")
コード例 #4
0
 def add_from_homepage_in_group(self, id, groupname):
     wd = self.app.wd
     self.app.open_home_page()
     wd.find_element_by_css_selector("input[value='%s']" % id).click()
     my_select = Select(wd.find_element_by_xpath("//div[@id='content']/form/select[1]"))
     my_select.select_by_visible_text(groupname)
     self.contact_cache = None
コード例 #5
0
    def create_product(self, name="Test Product", version="Test Version", desc="This is a test product", profile=None):
        dt_string = datetime.utcnow().isoformat()
        product = {}
        product["name"] = u"%(name)s %(dt_string)s" % {"name": name, "dt_string": dt_string}
        product["desc"] = u"%(desc)s created on %(dt_string)s" % {"desc": desc, "dt_string": dt_string}
        product["locator"] = (self._product_locator[0], self._product_locator[1] % {"product_name": product["name"]})
        product["version"] = {}
        product["version"]["name"] = u"%(version)s %(dt_string)s" % {"version": version, "dt_string": dt_string}
        product["version"]["manage_locator"] = (
            self._version_manage_locator[0],
            self._version_manage_locator[1]
            % {"product_name": product["name"], "version_name": product["version"]["name"]},
        )
        product["version"]["homepage_locator"] = (
            self._version_homepage_locator[0],
            self._version_homepage_locator[1]
            % {"product_name": product["name"], "version_name": product["version"]["name"]},
        )

        self.selenium.find_element(*self._name_locator).send_keys(product["name"])
        self.selenium.find_element(*self._version_locator).send_keys(product["version"]["name"])
        self.selenium.find_element(*self._description_locator).send_keys(product["desc"])
        if profile:
            profile_select = Select(self.selenium.find_element(*self._profile_locator))
            profile_select.select_by_visible_text(profile)
        self.selenium.find_element(*self._submit_locator).click()

        return product
コード例 #6
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)
コード例 #7
0
ファイル: WebNativeDatabase.py プロジェクト: mmguzman/Xinet
 def select_template_combo(self, template_name):
     """
     Selects the Integer Type option.
     """
     select = Select(self._driver.find_element(*self._templates_combo))
     select.select_by_visible_text(template_name)
     self._wait.until(ec.visibility_of_element_located(self._metadata_fields_table))
コード例 #8
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))
コード例 #9
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
コード例 #10
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()
コード例 #11
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()
コード例 #12
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
コード例 #13
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)
コード例 #14
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)
コード例 #15
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)
コード例 #16
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
        
コード例 #17
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()
コード例 #18
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()
コード例 #19
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
コード例 #20
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)
コード例 #21
0
 def test_13_selenium_select_default_organization_option(self):
     from selenium.webdriver.support.select import Select
     select_organization = Select(self.filters.new_filter_menu.organizations_field.element)
     select_organization.deselect_all()
     select_organization.select_by_visible_text("ACME_Corporation")
     selected_option_value = select_organization.first_selected_option.get_attribute('value')
     self.assertElementValue(self.filters.new_filter_menu.organizations_field.element, selected_option_value)
コード例 #22
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)
コード例 #23
0
ファイル: BasketBase.py プロジェクト: mmguzman/Xinet
 def _select_text_popup(self, value):
     """
     Selects the text_popup value.
     :param value: Value to select.
     """
     select = Select(self._driver.find_element(*self._text_popup_combobox))
     select.select_by_visible_text(value)
コード例 #24
0
ファイル: BasketBase.py プロジェクト: mmguzman/Xinet
 def select_format_option(self, format_name):
     """
     Select the Format option.
     :param format_name: The format to select.
     """
     select = Select(self._driver.find_element(*self._select_format_combobox))
     select.select_by_visible_text(format_name)
コード例 #25
0
ファイル: nav.py プロジェクト: cjames23/Personal
	def guest_checkout(self, firstname, lastname, email, country, address1, address2, city, state, zip):
		"""

		:param firstname: First Name of Guest
		:param lastname: Last Name of Guest
		:param email: valid email address of *@*.*
		:param country: United States or Canada
		:param address1: Street Address
		:param address2: Apartment etc.
		:param city: Valid City name
		:param state: Choose from list of states and Territories, including Puerto Rico, Guam, American Samoa,
		Northern Mariana Islands, United States Minor Outlying Islands, AA/AE/AP Military, Virgin Islands,
		And District of Columbia abbreviated as D.C.
		:param zip: Vaild 5 digit Zip Code or 6 alpha numeric zip code for Canada
		:return:
		"""
		self.driver.find_element_by_xpath('//*[@id="view-sitelogin"]/div[2]/div[3]/a').click()
		self.driver.find_element_by_id("Address_FirstName").send_keys(firstname)
		self.driver.find_element_by_id("Address_LastName").send_keys(lastname)
		self.driver.find_element_by_id("Address_Email").send_keys(email)
		country1 = Select(self.driver.find_element_by_id("Address_Country"))
		country1.select_by_visible_text(country)
		self.driver.find_element_by_id("Address_Address1").send_keys(address1)
		self.driver.find_element_by_name("Address.Address2").send_keys(address2)
		self.driver.find_element_by_id("Address_City").send_keys(city)
		self.driver.find_element_by_name("Address.State").click()
		state1 = Select(self.driver.find_element_by_name("Address.State"))
		state1.select_by_visible_text(state)
		self.driver.find_element_by_id("Address_Zip").send_keys(zip)
		self.driver.find_element_by_xpath('//*[@id="view-ordershipping"]/div[2]/div/form/div[3]/button').click()
コード例 #26
0
    def add_a_new_facility(self, facility):
        self.go_to_facilities()
        self.wait.until(EC.title_is('Facilities'))
        link = self.wait.until(EC.presence_of_element_located(
            (By.ID, 'id_add_new_facility_link')))
        link.click()
        self.wait.until(EC.title_is('Add New Facility'))
        inputbox = self.wait.until(
            EC.presence_of_element_located((By.ID, 'id_facility_name')))
        inputbox.send_keys(facility.name)
        self.browser.find_element_by_xpath(
            '//select[@id="id_facility_type"]/option[text()="%s"]' %
            facility.type).click()
        inputbox = self.wait.until(
            EC.presence_of_element_located((By.ID, 'id_facility_status')))
        inputbox.send_keys(facility.status)
        if facility.area:
            select = Select(self.browser.find_element_by_id('id_facility_area'))
            select.select_by_visible_text(unicode(facility.area))
        if facility.json:
            inputbox = self.wait.until(
                EC.presence_of_element_located((By.ID, 'id_json')))
            inputbox.send_keys(facility.json)

        submit = self.browser.find_element_by_id('id_submit_button')
        submit.click()
        self.wait.until(EC.title_is('Facilities'))
コード例 #27
0
    def select_option_with_text(self, select_locator, select_rule, visible_text=None, value=None, wait_timeout=-1):
        """Select the write option in a <select> element

        :param select_locator: the engine to process the rule
        :type select_locator: selenium.webdriver.common.by.By
        :param select_rule: the rule the <select> element must match
        :type select_rule: str
        :param visible_text: the text inside <option> tag. Must be used only if value is None
        :type visible_text: str
        :param value: the text inside value attribute for <option> tag. Must be used only if visible_text is None
        :type value: str
        :param wait_timeout: Number of second that we will poll the DOM. Once this is over, a TimeoutException is raised\
        if wait_timeout is negative, no wait will be processed
        :type wait_timeout: int
        :raises TimeoutException: when wait_timeout is provided and the select element is not found before timeout
        :raises NoSuchElementException: when Select element is not found our there no <option> child matching your \
        requirements
        :raises WebDriverException: when element exist but can't be accessed or when your driver failed to process the \
        selection action
        """
        if value is not None and visible_text is not None:
            raise ValueError("Can't select by visible text AND value")
        if value is None and visible_text is None:
            raise ValueError("You must select by value OR by visible text")
        if wait_timeout < 0:
            select = Select(self.driver.find_element(by=select_locator, value=select_rule))
        else:
            element = WebDriverWait(self.driver, wait_timeout).until(
                EC.element_to_be_clickable((select_locator, select_rule))
            )
            select = Select(element)
        if visible_text is not None:
            select.select_by_visible_text(visible_text)
        if value is not None:
            select.select_by_value(value)
コード例 #28
0
 def get_contact_in_group(self,group_name):
     if self.contact_cache is None:
         wd = self.app.wd
         self.open_home_form()
         # установим фильтр #выбор  имени группы
         #my_select = Select(wd.find_element_by_xpath("//div[@id='content']/form/select[5]"))
         my_select = Select(wd.find_element_by_xpath("/html/body/div[@id='container']/div[@id='content']/form[@id='right']/select"))
         my_select.select_by_visible_text(group_name)
         self.contact_cache=[]
         # бежим по таблице замисывая "строки" в массив
         rows =  wd.find_elements_by_xpath("//div[1]/div[4]/form[2]/table/tbody/tr[@name='entry']")
         for elements in rows:
             #теперь пробежим по столбцам текущего tr из цикла
             column = elements.find_elements_by_tag_name("td")
             firstname = column[2].text
             lastname = column[1].text
             id = elements.find_element_by_name("selected[]").get_attribute("value")
             all_phones = column[5].text
             all_emails = column[4].text
             self.contact_cache.append(Contact(lastname=lastname,firstname=firstname,id=id,
                                               all_phones_from_home_page = all_phones,
                                               # home=all_phones[0],
                                               # mobile=all_phones[1],
                                               # work=all_phones[2],
                                               # fax=all_phones[3],
                                               all_emails_from_home_page = all_emails,
                                               # email1=all_emails[0],
                                               # email2=all_emails[1],
                                               # email3=all_emails[2]
                                               )
                                       )
     return list(self.contact_cache)
コード例 #29
0
    def add_in_group(self, groupname):
        wd = self.app.wd
        self.app.open_home_page()

        my_select = Select(wd.find_element_by_xpath("//div[@id='content']/form/select[1]"))
        my_select.select_by_visible_text(groupname)
        self.contact_cache = None
コード例 #30
0
ファイル: nav.py プロジェクト: cjames23/Personal
	def by_designer_id(self, designerid):
		"""

        :param designerid: the designer id number of the designer being searched for
        :return:
        """
		self.driver.find_element_by_xpath('//*[@id="navigation"]/nav[1]/div/div[2]/ul/li[5]/a').click()
		self.driver.find_element_by_id("DesignerID").send_keys(designerid)
		self.driver.find_element_by_id("distributorId-search").click()

		def by_name(self, firstname, lastname, state):

			"""

			:param firstname: First Name of the Designer being searched for
			:param lastname: Last Name of the Designer Being searched for
			:param state: State where the designer lives
			:return:
			"""
		self.driver.find_element_by_xpath('//*[@id="navigation"]/nav[1]/div/div[2]/ul/li[5]/a').click()
		self.driver.find_element_by_id("dfirst").send_keys(firstname)

		self.driver.find_element_by_id("dlast").send_keys(lastname)
		self.driver.find_element_by_id("dstate").click()
		findstate = Select(self.driver.find_element_by_id("dstate"))
		findstate.select_by_visible_text(state)
		self.driver.find_element_by_id("info-search").click()
		if self.driver.find_element_by_id("noResults"):
			raise Exception("Designer Not Found")
		else:
			self.driver.find_element_by_link_text("CHOOSE").click()
コード例 #31
0
    def mnist_manual_02(self):

        # gpuper = "80"
        # coreper = "90"

        driver2 = self.driver2

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

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

        # ------Memory and core Percentages ----------
        percentages = Memory_and_Core_Percentages()
        gpuper = percentages.memory_08
        coreper = percentages.core_08
        # ------- Login Details ------------
        user = LoginUsers()
        Admin = user.user2_name
        Pwd = user.user2_password
        expadmin = user.user2_expadmin
        exppass = user.user2_exppass
        # ------ local path ------------
        paths = Paths()
        locGVpath = paths.Local_GVirtus_path
        Backendip = paths.Backend_ip

        admin_login = AdminLogin(driver2)
        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.driver2.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.driver2.find_element_by_xpath(
            "//*[@class='card-body text-center font-weight-normal btnNext']")
        inception.click()
        sleep(1)
        print("Selected Inception")

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

        sleep(2)

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

        print("Your selected Manual")
        manual = self.driver2.find_element_by_id("r102")
        manual.click()
        sleep(1)
        # ---------Backend IP --------------
        '''backendip = self.driver2.find_element(By.ID, 'gpuip0')
        backendip.clear()
        sleep(1)
        backendip.send_keys(Backendip)
        '''
        # ------ gpu percentage -----------
        memory0 = self.driver2.find_element(By.ID, 'gpupercent0')
        memory0.send_keys(gpuper)
        print("gpu percentage : ", gpuper, '%')
        # --------core percentage -----------
        sleep(1)
        gpuvalue = self.driver2.find_element(By.ID, 'gpuvalue0')
        gpuvalue.send_keys(coreper)
        print("core percentage : ", coreper, '%')
        sleep(8)
        # ------Screenshot-1-----------
        ss.ScreenShot(ss_path +
                      "test_parallel_02_mnist_manual2_setupsscreen.png")
        # -------------------- setup btn -----------------
        setupbtn = self.driver2.find_element(By.ID, 'setupbtn')
        setupbtn.click()
        sleep(25)

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

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

        # --------Elapsed Time -------------------
        myElem = self.driver2.find_element_by_id("elapsedTime")
        myElem.click()
        sleep(1)
        # ------Screenshot-2-----------
        ss.ScreenShot(ss_path +
                      "test_parallel_02_mnist_manual2_elapsedtime.png")
        sleep(2)
        assert isinstance(myElem.text, object)
        print("Mnist Manual -", str(myElem.text))

        try:

            pass

            # log = self.get_browser_console_log()
            # log = self.driver2.get_log(browser)
            # print("Console Log: ",log)
        except Exception as e:
            print("Exception Occurred :" + str(e))
        # ---------Logout ----------------
        self.driver2.find_element_by_id("navbarDropdownMenuLink").click()
        logout = self.driver2.find_element_by_class_name("dropdown-item")
        logout.click()
        sleep(5)
        for Logedout in self.driver2.find_elements_by_xpath(
                "//*[@class='alert alert-success']"):
            assert isinstance(Logedout.text, object)
            print(str(Logedout.text))
コード例 #32
0
    def test(self):

        driver = self.driver
        driver.get(self.baseUrl)
        driver.maximize_window()
        driver.implicitly_wait(5)

        wait = WebDriverWait(driver,
                             30,
                             poll_frequency=1,
                             ignored_exceptions=[
                                 NoSuchElementException,
                                 ElementNotVisibleException,
                                 ElementNotSelectableException
                             ])

        total = 0
        page_count = 1

        ## click and send key

        cursor = wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, "//*[@id='search-by-body-style-tab']/label")))
        cursor.click()

        bsid = driver.find_element_by_xpath("//select[contains(@name,'bsId')]")
        sel_id = Select(bsid)
        sel_id.select_by_visible_text(self.body_style)

        co = driver.find_element_by_xpath(
            "//select[contains(@name,'stockType')]")
        sel_co = Select(co)
        sel_co.select_by_visible_text(self.condition)

        max_ = driver.find_element_by_xpath("//select[contains(@name,'prMx')]")
        sel_max = Select(max_)
        sel_max.select_by_visible_text(self.max_price)

        dis = driver.find_element_by_xpath("//select[contains(@name,'rd')]")
        dis = Select(dis)
        dis.select_by_value(self.distance)

        zip_c = driver.find_element_by_xpath("//input[contains(@id,'zip')]")
        zip_c.clear()
        zip_c.send_keys(self.zip_code)

        search = driver.find_element_by_xpath(
            "//input[contains(@value,'Search')]")
        search.click()

        ## landing search page now!

        driver.execute_script("window.scrollTo(0, 50000)")
        page_show = wait.until(
            EC.presence_of_element_located(
                (By.XPATH, "/html/body//cui-page-result-count//select")))
        Select(page_show).select_by_value("100")

        time.sleep(5)
        self.year1 = wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 "//*[@id='srpFilters']/ul/li[3]/div[2]/div[2]/select")))
        driver.execute_script("window.scrollTo(0, 300)")
        self.year1 = Select(self.year1)
        self.year1.select_by_visible_text(self.year)

        time.sleep(5)
        self.year2 = wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 "//*[@id='srpFilters']/ul/li[3]/div[2]/div[1]/select")))
        driver.execute_script("window.scrollTo(0, 300)")
        self.year2 = Select(self.year2)
        self.year2.select_by_visible_text(self.year)

        # # anchor tag disable:https://github.com/angular/protractor/issues/577

        while (True):
            elements = wait.until(
                EC.presence_of_all_elements_located(
                    (By.XPATH, "//div//div[@class='listing-row__details']")))
            #elements = driver.find_elements_by_xpath("//div//div[@class='listing-row__details']")
            temp = pd.DataFrame({'object': elements})
            length = len(elements)
            print("there are " + str(length) + " records in page " +
                  str(page_count) + " time:" + str(dt.datetime.now()))
            next = driver.find_element_by_xpath("//a[contains(text(),'Next')]")

            temp = temp.apply(lambda x: self.find(x), axis=1).iloc[:, 1:]
            self.data = pd.concat([self.data, temp], axis=0, ignore_index=True)
            total = total + length
            if next.get_attribute('disabled') == None:
                driver.execute_script("window.scrollTo(0, 50000)")
                next.click()
                page_count = page_count + 1
            else:
                break

        print(self.data.head())

        print("there are " + str(total) + " in total")

        self.data.to_csv(str(self.body_style) + " " + str(self.zip_code) +
                         " " + "less than " + str(self.distance) + " miles" +
                         str(self.year) + " self.year.csv",
                         index=False)
コード例 #33
0
class leiwen_clawler(object):
    def __init__(self,
                 body_style="SUV",
                 condition="Used Cars",
                 max_price="$30,000",
                 zip_code=22202,
                 distance="100",
                 year="2008"):
        self.body_style = body_style
        self.condition = condition
        self.max_price = max_price
        self.zip_code = zip_code
        self.distance = distance
        self.year = year
        self.data = pd.DataFrame()
        self.baseUrl = "https://www.cars.com/"
        self.driver = webdriver.Chrome(driverLocation)

    def find(self, obj):
        obj["year"] = self.year
        try:
            obj["mile"] = obj["object"].find_element_by_xpath(
                ".//span[contains(@class,'listing-row__mileage')]").text
        except:
            obj["mile"] = "unknown"

        try:
            obj["name"] = obj["object"].find_element_by_xpath(
                ".//h2[contains(@class,'cui-delta listing-row__title')]").text
        except:
            obj["name"] = "unknown"

        try:
            obj["price"] = obj["object"].find_element_by_xpath(
                ".//span[contains(@class,'listing-row__price')]").text
        except:
            obj["price"] = "unknown"

        try:
            obj["hyperlink"] = obj["object"].find_element_by_xpath(
                ".//a").get_attribute('href')
        except:
            obj["hyperlink"] = "unknown"

        try:
            obj["deal_qualilty"] = obj["object"].find_element_by_xpath(
                ".//div[contains(@class,'listing-row__price-badge-arrow')]//span"
            ).text
        except:
            obj["deal_qualilty"] = "NOT A GOOD DEAL"

        try:
            attributes = obj["object"].find_elements_by_xpath(
                ".//ul[contains(@class,'listing-row__meta')]//li")
            attribute = str()
            for i in attributes:
                attribute = attribute + "," + i.text
                obj["other_attributes"] = attribute[1:]
        except:
            obj["other_attributes"] = "unknown"
        return obj

    def test(self):

        driver = self.driver
        driver.get(self.baseUrl)
        driver.maximize_window()
        driver.implicitly_wait(5)

        wait = WebDriverWait(driver,
                             30,
                             poll_frequency=1,
                             ignored_exceptions=[
                                 NoSuchElementException,
                                 ElementNotVisibleException,
                                 ElementNotSelectableException
                             ])

        total = 0
        page_count = 1

        ## click and send key

        cursor = wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, "//*[@id='search-by-body-style-tab']/label")))
        cursor.click()

        bsid = driver.find_element_by_xpath("//select[contains(@name,'bsId')]")
        sel_id = Select(bsid)
        sel_id.select_by_visible_text(self.body_style)

        co = driver.find_element_by_xpath(
            "//select[contains(@name,'stockType')]")
        sel_co = Select(co)
        sel_co.select_by_visible_text(self.condition)

        max_ = driver.find_element_by_xpath("//select[contains(@name,'prMx')]")
        sel_max = Select(max_)
        sel_max.select_by_visible_text(self.max_price)

        dis = driver.find_element_by_xpath("//select[contains(@name,'rd')]")
        dis = Select(dis)
        dis.select_by_value(self.distance)

        zip_c = driver.find_element_by_xpath("//input[contains(@id,'zip')]")
        zip_c.clear()
        zip_c.send_keys(self.zip_code)

        search = driver.find_element_by_xpath(
            "//input[contains(@value,'Search')]")
        search.click()

        ## landing search page now!

        driver.execute_script("window.scrollTo(0, 50000)")
        page_show = wait.until(
            EC.presence_of_element_located(
                (By.XPATH, "/html/body//cui-page-result-count//select")))
        Select(page_show).select_by_value("100")

        time.sleep(5)
        self.year1 = wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 "//*[@id='srpFilters']/ul/li[3]/div[2]/div[2]/select")))
        driver.execute_script("window.scrollTo(0, 300)")
        self.year1 = Select(self.year1)
        self.year1.select_by_visible_text(self.year)

        time.sleep(5)
        self.year2 = wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 "//*[@id='srpFilters']/ul/li[3]/div[2]/div[1]/select")))
        driver.execute_script("window.scrollTo(0, 300)")
        self.year2 = Select(self.year2)
        self.year2.select_by_visible_text(self.year)

        # # anchor tag disable:https://github.com/angular/protractor/issues/577

        while (True):
            elements = wait.until(
                EC.presence_of_all_elements_located(
                    (By.XPATH, "//div//div[@class='listing-row__details']")))
            #elements = driver.find_elements_by_xpath("//div//div[@class='listing-row__details']")
            temp = pd.DataFrame({'object': elements})
            length = len(elements)
            print("there are " + str(length) + " records in page " +
                  str(page_count) + " time:" + str(dt.datetime.now()))
            next = driver.find_element_by_xpath("//a[contains(text(),'Next')]")

            temp = temp.apply(lambda x: self.find(x), axis=1).iloc[:, 1:]
            self.data = pd.concat([self.data, temp], axis=0, ignore_index=True)
            total = total + length
            if next.get_attribute('disabled') == None:
                driver.execute_script("window.scrollTo(0, 50000)")
                next.click()
                page_count = page_count + 1
            else:
                break

        print(self.data.head())

        print("there are " + str(total) + " in total")

        self.data.to_csv(str(self.body_style) + " " + str(self.zip_code) +
                         " " + "less than " + str(self.distance) + " miles" +
                         str(self.year) + " self.year.csv",
                         index=False)
コード例 #34
0
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By

driver = webdriver.Chrome("./chromedriver")
driver.get("https://rahulshettyacademy.com/angularpractice/")

driver.find_element(By.CSS_SELECTOR, "input[name='name']").send_keys("Test")
driver.find_element(By.NAME, "email").send_keys("*****@*****.**")
driver.find_element(By.ID, "exampleInputPassword1").send_keys("test123")
driver.find_element(By.ID, "exampleCheck1").click()
dropdown = Select(driver.find_element(By.ID, "exampleFormControlSelect1"))
dropdown.select_by_visible_text(
    "Female")  #When the dropdown options are visible
dropdown.select_by_index("0")  #Index of the dropdown options
driver.find_element(By.CSS_SELECTOR,
                    "input[name='inlineRadioOptions']").click()
driver.find_element(By.XPATH, "//input[@type='submit']").click()
message = driver.find_element(By.CLASS_NAME, "alert-success").text
print(message)
assert "Success" in message
コード例 #35
0
ファイル: airlines.py プロジェクト: Vignesh1911/Selenium
driver.implicitly_wait(10)
driver.maximize_window()

driver.get("https://www.goibibo.com/")
driver.find_element_by_id("gosuggest_inputSrc").click()
driver.find_element_by_id("gosuggest_inputSrc").clear()
driver.find_element_by_id("gosuggest_inputSrc").send_keys("Montevideo (MVD)")
driver.find_element_by_id("gosuggest_inputDest").click()
driver.find_element_by_id("gosuggest_inputDest").clear()
driver.find_element_by_id("gosuggest_inputDest").send_keys("Chennai (MAA)")

driver.find_element_by_id("otros").click()

s1 = Select(driver.find_element_by_id('otros'))
time.sleep(5)
s1.select_by_visible_text('India')
time.sleep(7)
driver.find_element_by_xpath("//input[@id='documento_persona']").send_keys(
    "K2499214")
driver.find_element_by_xpath(
    "//form[@id='formLogin']//button[@class='btn btn--main-color btn-block'][contains(text(),'Ingresar')]"
).click()
time.sleep(20)
driver.find_element_by_xpath(
    "//input[@id='ctl00_MainHolder_LoginControlPeople_textPasswordVisible']"
).click()
driver.find_element_by_xpath(
    "//input[@id='ctl00_MainHolder_LoginControlPeople_textPasswordVisible']"
).send_keys("fuckyou")

driver.find_element_by_xpath(
コード例 #36
0
class dropdown(controlBase):

    def __init__(self, driver, selector: dict = None, element=None):
        super().__init__(driver, selector, element)
        self.__selectElement = Select(self.wrappedElement)

    @property
    def SelectedLabel(self):
        return self.__selectElement.first_selected_option.text.strip()

    @property
    def SelectedValue(self):
        return self.__selectElement.first_selected_option.get_attribute('value')

    @property
    def AllSelectedOptions(self):
        return self.__selectElement.all_selected_options

    def SelectByText(self, text):
        self.__selectElement.select_by_visible_text(text)

    def DeSelectByText(self, text):
        self.__selectElement.deselect_by_visible_text(text)

    def SelectByTextLike(self, text):
        options = self.__selectElement.options
        for option in options:
            if option.text.Contains(text):
                self.__selectElement.select_by_visible_text(option.text)
                return
        raise AssertionError(f'No option found with such text {text}.')

    def SelectByValue(self, value):
        self.__selectElement.select_by_value(value)

    def DeSelectByValue(self, value):
        self.__selectElement.deselect_by_value(value)

    def SelectByIndex(self, index):
        if self.HasEmptyString:
            self.__selectElement.select_by_index(index)
        else:
            self.__selectElement.select_by_index(index - 1)

    def DeSelectByIndex(self, index):
        if self.HasEmptyString:
            self.__selectElement.deselect_by_index(index)
        else:
            self.__selectElement.deselect_by_index(index-1)

    def DeSelectAll(self):
        self.__selectElement.deselect_all()

    @property
    def AllSelectedOptions(self):
        return self.__selectElement.all_selected_options

    @property
    def AllOptions(self):
        return self.__selectElement.options

    @property
    def Labels(self):
        if self.DoesOptionExist:
            return query(self.AllOptions) \
                .select(lambda option: option.text.strip()).where(lambda label: label != '').to_list()
        else:
            return []

    @property
    def HasEmptyString(self):
        if self.DoesOptionExist:
            return query(self.AllOptions) \
                .select(lambda option: option.text.strip()).any(lambda label: label == '')
        else:
            return True

    @property
    def Options(self):
        return query(self.AllOptions).select(lambda e: dropdownOption(self.webDriver, None, e))

    @property
    def Values(self):
        if self.DoesOptionExist:
            return query(self.AllOptions) \
                .select(lambda option: option.get_attribute('value')).where(lambda value: value != '').to_list()
        else:
            return []

    @property
    def IsMultiSelectDropDown(self):
        return self.__selectElement.is_multiple

    @property
    def DoesOptionExist(self):
        return self.__selectElement.options is not None
コード例 #37
0
def findSelectText(driver, id, str):
    select = Select(findId(driver, id))
    select.select_by_visible_text(str)
    return select
コード例 #38
0
 def select_by_text(self, text):
     select_option_text = Select(self.driver.find_element(*self.order))
     # Seleccionar por el texto visible, le pasamos como parámetro text
     select_option_text.select_by_visible_text(text)
コード例 #39
0
ファイル: BaseClass.py プロジェクト: sanpry/GitDemo
 def selectDropdown(self, locator, text):
     dropDown = Select(locator)
     dropDown.select_by_visible_text(text)
コード例 #40
0
 def Select_By_Visible_Text_From_DropDown(self, locator, str_data):
     data = self.driver.find_element_by_xpath(locator)
     sel = Select(data)
     sel.select_by_visible_text(str_data)
コード例 #41
0
from selenium import webdriver
from selenium.webdriver.support.select import Select
import time

base_url = "https://google.co.in"
chrome_driver_path = r"C:\Users\nthallap\Downloads\drivers\chromedriver.exe"

driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.implicitly_wait(10)
driver.set_page_load_timeout(30)

driver.get("https://letskodeit.teachable.com/p/practice")
driver.maximize_window()

drop_down = driver.find_element_by_xpath("//select[@id='carselect']")
sel = Select(drop_down)
sel.select_by_index(2)
time.sleep(3)
sel.select_by_visible_text("BMW")
time.sleep(3)
sel.select_by_value("benz")
time.sleep(3)
sel.select_by_index('0')
driver.quit()
コード例 #42
0
 def select_a_search_department(self, department_name):
     department_select = Select(self.find_element(self.department_dropdown_loc))
     department_select.select_by_visible_text(department_name)
コード例 #43
0
    def test_02_symbols(self):
        symbols = '!#$%&()*+,-./:;<=>?@[\]^_`{|}~'

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

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New workflow', self.selenium.page_source)
        self.assertIn('Import workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text('sss')
        wf_link.click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Select the email column and click in the edit button
        self.selenium.find_element_by_xpath(
            "//table[@id='column-table']/tbody/tr[3]/td[5]/div/button").click(
            )
        self.selenium.find_element_by_xpath(
            "//table[@id='column-table']/tbody/tr[3]/td[5]/div/ul/li[1]/button"
        ).click()
        # Wait for the form to create the derived column
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Edit column'))

        # Append symbols to the name
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").send_keys(symbols)

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

        # Select the age column and click in the edit button
        self.selenium.find_element_by_xpath(
            "//table[@id='column-table']/tbody/tr[4]/td[5]/div/button").click(
            )
        self.selenium.find_element_by_xpath(
            "//table[@id='column-table']/tbody/tr[4]/td[5]/div/ul/li[1]/button"
        ).click()
        # Wait for the modal to open
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Edit column'))

        # Append symbols to the name
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").send_keys(symbols)

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

        # Go to the table link
        self.selenium.find_element_by_link_text("Table").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Verify that everything appears normally
        self.assertIn(escape(symbols), self.selenium.page_source)
        self.assertIn('<td class=" dt-center">12</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">12.1</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">13.2</td>',
                      self.selenium.page_source)

        # Go to the actions page
        self.selenium.find_element_by_link_text("Actions").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'action-table_previous')))

        # Edit the action-in at the top of the table
        self.selenium.find_element_by_link_text("Edit").click()

        # Set the correct values for an action-in
        # Set the right columns to process
        select = Select(
            self.selenium.find_element_by_id('select-key-column-name'))
        select.select_by_visible_text('email')
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.CLASS_NAME, 'js-workflow-column-edit')))

        # Done editing the action in
        self.selenium.find_element_by_link_text('Done').click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'action-table_previous')))

        # Click in the run link
        self.selenium.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')))

        # Click on the first value
        self.selenium.find_element_by_link_text("*****@*****.**").click()

        # Modify the value of the column
        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(
            "14")
        # Submit changes to the first element
        self.selenium.find_element_by_xpath(
            "(//button[@name='submit'])[1]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'actioninrun-data_previous')))

        # Click on the second value
        self.selenium.find_element_by_link_text("*****@*****.**").click()

        # Modify the value of the column
        self.selenium.find_element_by_id("id____ontask___select_1").clear()
        self.selenium.find_element_by_id("id____ontask___select_1").send_keys(
            "15")
        # Submit changes to the second element
        self.selenium.find_element_by_xpath(
            "(//button[@name='submit'])[1]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'actioninrun-data_previous')))

        # Click on the third value
        self.selenium.find_element_by_link_text("*****@*****.**").click()

        # Modify the value of the column
        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(
            "16")
        # Submit changes to the second element
        self.selenium.find_element_by_xpath(
            "(//button[@name='submit'])[1]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'actioninrun-data_previous')))

        # Click in the back link!
        self.selenium.find_element_by_xpath(
            "(//button[@type='button'])[2]").click()
        # Wait for page to refresh
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'action-table_previous')))

        # Go to the table page
        self.selenium.find_element_by_link_text("Table").click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # Assert the new values
        self.assertIn('<td class=" dt-center">14</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">15</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">16</td>',
                      self.selenium.page_source)

        # End of session
        self.logout()
コード例 #44
0
# Fetching Title

print('Title of page is ' + driver.title)

# Fetch URL of Page

print('Page URL is ' + driver.current_url)

# Fetch Complete Page HTML
print('***************************************************')
print(driver.page_source)'''
'''
# Fetching element text

print('Text on link is : - ' + driver.find_element_by_class_name("displayPopup").text)

# Fetching attribute value of element

print('Value of Button is ' + driver.find_element_by_xpath("//input[@type='submit']").get_attribute('value'))
'''

# work on dropdown
obj = Select(driver.find_element_by_name('sex'))
obj.select_by_visible_text('Male')

# fetch select option

print(obj.first_selected_option.text)

for op in obj.options:
    print(op.text)
コード例 #45
0
 def selectOptionByText(self, locator, text):
     sel = Select(locator)
     sel.select_by_visible_text(text)
コード例 #46
0
    def test_01_symbols(self):
        symbols = '!#$%&()*+,-./:;<=>?@[\]^_`{|}~'

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

        self.open(reverse('workflow:index'))

        # GO TO THE WORKFLOW PAGE
        WebDriverWait(self.selenium,
                      10).until(EC.title_is('OnTask :: Workflows'))
        self.assertIn('New workflow', self.selenium.page_source)
        self.assertIn('Import workflow', self.selenium.page_source)

        # Open the workflow
        wf_link = self.selenium.find_element_by_link_text('sss')
        wf_link.click()
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Edit the name column
        self.selenium.find_element_by_xpath(
            "//table[@id='column-table']/tbody/tr[4]/td[5]/div/button").click(
            )
        self.selenium.find_element_by_xpath(
            "//table[@id='column-table']/tbody/tr[4]/td[5]/div/ul/li[1]/button"
        ).click()
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located((By.ID, 'id_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
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'column-table_previous')))

        # Click in the New Column button
        self.selenium.find_element_by_class_name(
            'js-workflow-column-add').click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Add 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.selenium.find_element_by_xpath(
            "//div[@id='workflow-area']/div/button[3]").click()
        self.selenium.find_element_by_link_text('Attributes').click()
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'js-attribute-create')))

        # Delete the existing one and confirm deletion
        self.selenium.find_element_by_xpath(
            "//table[@id='attribute-table']/tbody/tr/td[3]/button[2]").click()
        # Wait for the delete confirmation frame
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'modal-title'),
                                             'Confirm attribute deletion'))
        # Click in the delete confirm button
        self.selenium.find_element_by_xpath(
            "//div[@class='modal-footer']/button[2]").click()
        # MODAL WAITING
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for the table to be refreshed
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'attribute-table_previous')))

        # Add a new attribute and insert key (symbols) and value
        self.selenium.find_element_by_xpath(
            "(//button[@type='button'])[2]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, "//div[@id='modal-item']/div/div/form/div/h4"),
                'Create attribute'))

        # Add key and value
        self.selenium.find_element_by_id("id_key").click()
        self.selenium.find_element_by_id("id_key").clear()
        self.selenium.find_element_by_id("id_key").send_keys(symbols + '3')
        self.selenium.find_element_by_id("id_value").click()
        self.selenium.find_element_by_id("id_value").clear()
        self.selenium.find_element_by_id("id_value").send_keys("vvv")

        # Submit new attribute
        self.selenium.find_element_by_xpath(
            "//div[@class='modal-footer']/button[2]").click()
        # MODAL WAITING
        self.wait_close_modal_refresh_table('attribute-table_previous')

        # Save and close the attribute page
        self.selenium.find_element_by_link_text('Back').click()
        # Wait for the details page
        self.wait_close_modal_refresh_table('column-table_previous')

        # Click in the TABLE link
        self.selenium.find_element_by_link_text("Table").click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-data_previous')))

        # 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.selenium.find_element_by_link_text("Actions").click()

        # Edit the action-in
        self.selenium.find_element_by_link_text("Edit").click()

        # Set the right columns to process
        select = Select(self.selenium.find_element_by_id('select-column-name'))
        select.select_by_visible_text('!#$%&()*+,-./:;<=>?@[\]^_`{|}~2')
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'column-selected-table_previous')))
        select = Select(
            self.selenium.find_element_by_id('select-key-column-name'))
        select.select_by_visible_text('sid')
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'column-selected-table_previous')))
        select = Select(
            self.selenium.find_element_by_id('select-key-column-name'))
        select.select_by_visible_text('email')
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located(
                (By.ID, 'column-selected-table_previous')))

        # Save action-in
        self.selenium.find_element_by_link_text('Done').click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'action-table_previous')))

        # Click in the RUN link of the action in
        self.selenium.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.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(
            "//body/div[4]/div/form/button[1]/span").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.selenium.find_element_by_xpath(
            "(//button[@type='button'])[2]").click()
        # Wait for paging widget
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'action-table_previous')))

        # Edit the action out
        self.selenium.find_element_by_xpath(
            "//table[@id='action-table']/tbody/tr[2]/td[5]/div/a").click()

        # Insert attribute
        self.selenium.find_element_by_id("select-attribute-name").click()
        Select(self.selenium.find_element_by_id(
            "select-attribute-name")).select_by_visible_text("- Attribute -")

        # Insert column name
        self.selenium.find_element_by_id("select-column-name").click()
        Select(self.selenium.find_element_by_id(
            "select-column-name")).select_by_visible_text(symbols)

        # Insert second column name
        self.selenium.find_element_by_id("select-column-name").click()
        Select(self.selenium.find_element_by_id(
            "select-column-name")).select_by_visible_text(symbols + '2')

        # Create new condition
        self.selenium.find_element_by_xpath(
            "(//button[@type='button'])[3]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_description_text')))

        # Set the values of the condition
        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 + "4")
        self.selenium.find_element_by_id("id_description_text").click()
        self.selenium.find_element_by_name("builder_rule_0_filter").click()
        Select(self.selenium.find_element_by_name(
            "builder_rule_0_filter")).select_by_visible_text(symbols)
        self.selenium.find_element_by_name("builder_rule_0_operator").click()
        Select(self.selenium.find_element_by_name(
            "builder_rule_0_operator")).select_by_visible_text("begins with")
        self.selenium.find_element_by_name("builder_rule_0_value_0").click()
        self.selenium.find_element_by_name("builder_rule_0_value_0").clear()
        self.selenium.find_element_by_name("builder_rule_0_value_0").send_keys(
            "C")

        # Save the condition
        self.selenium.find_element_by_xpath(
            "(//button[@type='submit'])[2]").click()
        self.wait_close_modal_refresh_table('html-editor')

        # Create a filter
        self.selenium.find_element_by_xpath(
            "(//button[@type='button'])[2]").click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_description_text')))

        # Fill in the details
        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_name("builder_rule_0_filter").click()
        Select(self.selenium.find_element_by_name(
            "builder_rule_0_filter")).select_by_visible_text(symbols + "2")
        self.selenium.find_element_by_name("builder_rule_0_operator").click()
        Select(self.selenium.find_element_by_name("builder_rule_0_operator")
               ).select_by_visible_text("doesn't begin with")
        self.selenium.find_element_by_name("builder_rule_0_value_0").click()
        self.selenium.find_element_by_name("builder_rule_0_value_0").clear()
        self.selenium.find_element_by_name("builder_rule_0_value_0").send_keys(
            "x")
        # Save the filter
        self.selenium.find_element_by_xpath(
            "(//button[@type='submit'])[2]").click()
        WebDriverWait(self.selenium, 10).until_not(
            EC.presence_of_element_located((By.CLASS_NAME, 'modal-open')))
        # Wait for page to reload
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.XPATH, "//h4[@id='filter-set']/div/button")))

        # Click the preview button
        self.selenium.find_element_by_xpath(
            "//div[@id='html-editor']/form/div[3]/button").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()

        # End of session
        self.logout()
コード例 #47
0
from selenium import webdriver
from selenium.webdriver.support.select import Select

driver = webdriver.Chrome(
    executable_path=
    'C:\\Users\\JagguMiniPC\\PycharmProjects\\PythonSelenium\\Executables\\chromedriver.exe'
)
# driver = webdriver.Firefox(executable_path='C:\\Users\\JagguMiniPC\\PycharmProjects\\PythonSelenium\\Executables\\geckodriver.exe')
driver.get("https://rahulshettyacademy.com/angularpractice/")
# driver.get("https://rahulshettyacademy.com/AutomationPractice/")
driver.maximize_window()
driver.implicitly_wait(5000)
print(driver.title)
# driver.current_url
# driver.refresh()
# driver.back()
driver.find_element_by_css_selector("input[name='name']").send_keys("J")
driver.find_element_by_name("email").send_keys("R")
driver.find_element_by_id("exampleCheck1").click()

dropdown = Select(driver.find_element_by_id("exampleFormControlSelect1"))
dropdown.select_by_visible_text("Male")

driver.find_element_by_xpath("//input[@type='submit']").click()
driver.quit()
コード例 #48
0
browser.get('https://mbasic.facebook.com/')
# time.sleep(5)
user = "******"
password = "******"
browser.find_element_by_name("email").send_keys(user)
# time.sleep(2)
browser.find_element_by_name("pass").send_keys(password)
browser.find_element_by_name("login").click()
browser.find_element_by_class_name("bl.bm.bn.bo.bp.bq").click()
v = Select(browser.find_element_by_name("verification_method"))
v.select_by_index(1)
browser.find_element_by_class_name("bi.bj.bk.bl.bm.bn").click()
date = Select(browser.find_element_by_name("birthday_captcha_day"))
date.select_by_index(25)
month = Select(browser.find_element_by_name("birthday_captcha_month"))
month.select_by_visible_text("Sep")
year = Select(browser.find_element_by_name("birthday_captcha_year"))
for opt in year.options:
    year.select_by_visible_text("2001")
browser.find_element_by_class_name("bj.bk.bl.bm.bn.bo").click()
browser.find_element_by_class_name("bg.bh.bi.bj.bk.bl").click()
browser.find_element_by_class_name("bh.bf.bg").click()
browser.find_element_by_xpath(
    "//*[@id=\"m-timeline-cover-section\"]/div[3]/a[2]").click()
browser.find_element_by_xpath(
    "//*[@id=\"root\"]/div[1]/div[2]/div/div[2]/div[1]/table/tbody/tr/td[2]/a"
).click()
browser.find_element_by_xpath("//*[@id=\"u_0_i\"]/footer/div[2]/a[1]").click()
browser.find_element_by_xpath("//*[@id=\"composerInput\"]").send_keys(
    "Happy Birthday!!")
browser.find_element_by_xpath(
コード例 #49
0
 def select_quantity(self, option):
     select = Select(
         self.driver.wait.until(
             EC.presence_of_element_located(self.SELECT_QUANTITY_LOCATOR)))
     select.select_by_visible_text(option)
     sleep(2)
コード例 #50
0
ファイル: CustomerEnrol.py プロジェクト: vidyamb/SwagLabs
driver.find_element_by_id("inputPassword3").send_keys("PAss@1234")
driver.find_element_by_xpath("//button[@type='button']").click()

wait = WebDriverWait(driver, 50)
wait.until(
    expected_conditions.presence_of_element_located(
        (By.XPATH,
         '//body/ui-view[1]/div[1]/aside[1]/section[1]/ul[1]/li[3]/a[1]')))
driver.find_element_by_xpath(
    "//body/ui-view[1]/div[1]/aside[1]/section[1]/ul[1]/li[3]/a[1]").click()
wait.until(
    expected_conditions.presence_of_element_located(
        (By.XPATH, "//section/ul[@class='sidebar-menu']/li[3]/ul/li[2]/a")))

indvCustom = driver.find_element_by_xpath(
    "//section/ul[@class='sidebar-menu']/li[3]/ul/li[2]/a")
time.sleep(5)
ActionChains(driver).move_to_element(indvCustom).click(indvCustom).perform()
time.sleep(5)
branchName = Select(driver.find_element_by_css_selector("#customerBranchId"))
branchName.select_by_visible_text("Head Office")
time.sleep(3)
spokeName = Select(driver.find_element_by_id("centreId"))
spokeName.select_by_index(1)
time.sleep(3)
gallery = driver.find_element_by_xpath(
    "//div[@id='PERSONAL_INFORMATION']//div//button")
gallery.send_keys("C:\\Users\\vidya\\Downloads\\image.jpg")
# driver.back()
# driver.refresh()
コード例 #51
0
def run():

    months = calendar.month_name[1:13]
    dates =  [i for i in range(1,32) ]
    years =  [i for i in range(1990,2000) ]
    outputfile = "Output.json"
    adjetives = ['Expert', 'Gran Master', 'Master', 'Senior', 'Ninja', 'Masine Learning', 'Data Visualisation']
    emaildomains = ['@outlook.com']
    fake = Faker()


    driver = webdriver.Edge()

    driver.get("https://signup.live.com/")

    elem = driver.find_element_by_id("MemberName")

    speak("Tell the username")

    usern = get_audio()
    username = remove(usern)
    print("Email : "+username+"@outlook.com")

    elem.send_keys(username+"@outlook.com")

    driver.find_element_by_id("iSignupAction").click()

    sleep(6)

    elem = driver.find_element_by_id("PasswordInput")

    passwordt = password()
    print("Password : "******"iSignupAction").click()

    sleep(3)

    elem = driver.find_element_by_id("FirstName")

    speak("Tell the first name")

    fname = get_audio()
    firstname = remove(fname)

    elem.send_keys(firstname)

    elem = driver.find_element_by_id("LastName")

    speak("tell the last name")

    lname = get_audio()
    lastname = remove(lname)

    elem.send_keys(lastname)

    driver.find_element_by_id("iSignupAction").click()

    sleep(3)

    select = Select(driver.find_element_by_id('Country'))

    countryf=fake.country()

    select.select_by_visible_text(countryf)

    select = Select(driver.find_element_by_id('BirthMonth'))

    month = random.choice(months)

    select.select_by_visible_text(month)

    select = Select(driver.find_element_by_id('BirthDay'))

    date = "{}".format(random.choice(dates))

    select.select_by_visible_text(date)

    select = Select(driver.find_element_by_id('BirthYear'))

    year = "{}".format(random.choice(years))

    select.select_by_visible_text(year)

    driver.find_element_by_id("iSignupAction").click()

    sleep(3)

    
    file_name = username+"@outlook.com" + "-Generate-by-AI_Email.txt"
    with open(file_name, "w") as f:
        f.write("[+]========== This Email is Generated Using Mark42 Email Generator ==========[+]\nDeveloped by Yehan Wasura\n\nEmail : "+ username+"@outlook.com"+"\n\nPassword :"******"C:/Windows/notepad.exe", file_name])
    print("\n\n A TXT file has created in the directory, including login credentials")
    speak(" A TXT file has created in the directory, including login credentials")
コード例 #52
0
def excuse_violation(driver, parameters):
    delay = parameters['delay']
    # pause on next line for entry of credentials, and window navigation.
    waitForUser('VPS login / Navigate to "Violator Maintenance"')
    startWindow = findTargetPage(driver, findStartWindowDelay, parameters['startPageTextLocator'], "framename")
    if startWindow is None:
        print "Start Page not found."
        return None
    with open(parameters['dataInFileName'], 'r') as infile, open(parameters['dataOutFileName'], 'a') as outfile:
        outfile.truncate()
        csvInput = csv.reader(infile)
        for row in csvInput:   # find a way to detect last row or no new row.
            rawString = row[7]
            if rawString == "" or rawString == 0:  #end when input does not exist
                break
            inputString = cleanUpString(rawString)
            # skip the header
            if string.rfind(inputString, "NTTA") > -1:
                continue
            # check for Violation Excusal page
            # # foundFrame = findAndSelectFrame(driver, delay, "mainframe")
            headerElement = findElementOnPage(driver, delay, (By.XPATH, '//H1[contains(text(), "Violator Maintenance")]'))
            element = findElementOnPage(driver, delay, parameters['inputLocator'])
            submitted = fillFormAndSubmit(driver, startWindow, element, inputString, parameters)
            #check for excusal page found  ????
            time.sleep(1)
            #driver.switch_to_default_content()
            pageLoaded = newPageElementFound(driver, delay, (By.XPATH, '//frame[@name="fraTOP"]'), parameters['headerLocator'])
            #move to the correct frame
            foundFrame = findAndSelectFrame(driver, delay, "fraVF") # #####################
            # TABEL of name and addre
            # table of  invoice stuff
            # table of invoice details   if  non zero, excuse
            # table of  stuff with dmv information
            # get and save zip cash link
            # table of the rest - "Violator ID:" get next link, click. --> "Violator Details Screen"
            # click violation excuseal

            # check for ZipCash


            #select from drop down menu
            # if the menu is missing check for reason excused
            menuLocator = (By.XPATH, '//select[@name="P_L_EXR_EXCUSED_REAS_DESCR"]')
            menuElement = findElementOnPage(driver, delay, menuLocator)
            # menu select is sometimes None, why ?
            Selector = Select(menuElement)
            count = 0
            while Selector is None:
                count = count + 1
                print "retrying excusal menu selection. Count: ", count
                Selector = Select(menuElement)
            Selector.select_by_visible_text("Bankruptcy") # does this need to be instanciated each time?

            #click excuse button
            parameters['buttonLocator'] = (By.XPATH,'//input[@value="Excuse"]')
            clicked = findAndClickButton(driver, delay, parameters)
            # #time.sleep(1)
            driver.switch_to_default_content()
            pageLoaded = newPageElementFound(driver, delay, (By.XPATH, '//frame[@name="fraTOP"]'), parameters['headerLocator'])

            #navigate to search page / frame position
            foundFrame = findAndSelectFrame(driver, delay, "fraRL")
            parameters['buttonLocator'] = (By.XPATH,'//input[@value="Query"]')
            clicked = findAndClickButton(driver, delay, parameters)
            # #time.sleep(1)
            pageLoaded = newPageElementFound(driver, delay, None, parameters['headerLocator'])

    print "main: Finished individual violation excusal."
コード例 #53
0
        "name": name,
        "codename": codename,
        "rareness": rareness,
        "tag": tag,
    }


options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome("chromedriver", options=options)

op_url = "http://prts.wiki/w/%E5%B9%B2%E5%91%98%E4%B8%80%E8%A7%88"

driver.get(op_url)
select = Select(driver.find_element_by_id("per-page"))
select.select_by_visible_text("500")
op_content = driver.page_source
op_soup = BeautifulSoup(op_content, "html5lib")

with open(
        os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "tags.json",
        ),
        "r",
) as f:
    tags_dict = json.load(f)

success = 0
operators = []
コード例 #54
0
from selenium import webdriver
import time
from selenium.webdriver import ActionChains
from selenium.webdriver.support.select import Select

from Locators.Constants import Constants

driver = webdriver.Chrome(executable_path=Constants.driver)
driver.get(
    "https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407")
driver.maximize_window()

select = Select(driver.find_element_by_id('RESULT_RadioButton-9'))
select.select_by_visible_text('Morning')
# time.sleep(2)
driver.find_element_by_xpath(
    "//*[@id='q26']/table/tbody/tr[2]/td/label").click()
# print(select.options)
driver.find_element_by_xpath(
    "//*[@id='q15']/table/tbody/tr[1]/td/label").click()
driver.find_element_by_xpath(
    "//*[@id='q15']/table/tbody/tr[3]/td/label").click()
# driver.find_element_by_css_selector("select[id='speed'][visible_text='Medium']")
コード例 #55
0
    def test_02_symbols(self):
        symbols = '!#$%&()*+,-./:;<=>?@[\]^_`{|}~'

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

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

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

        # Append symbols to the name
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").send_keys(symbols)

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

        # Select the age column and click in the edit button
        self.open_column_edit('age')

        # Append symbols to the name
        self.selenium.find_element_by_id("id_name").click()
        self.selenium.find_element_by_id("id_name").send_keys(symbols)

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

        # Go to the table link
        self.go_to_table()

        # Verify that everything appears normally
        self.assertIn(escape(symbols), self.selenium.page_source)
        self.assertIn('<td class=" dt-center">12</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">12.1</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">13.2</td>',
                      self.selenium.page_source)

        # Go to the actions page
        self.go_to_actions()

        # Edit the action-in at the top of the table
        self.open_action_edit('action in')

        # Set the correct values for an action-in
        # Set the right columns to process
        select = Select(self.selenium.find_element_by_id(
            'select-key-column-name'
        ))
        select.select_by_visible_text('email' + symbols)
        # This wait is incorrect. Don't know how to wait for an AJAX call.
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        # Done editing the action in
        self.selenium.find_element_by_link_text('Done').click()
        self.wait_for_datatable('action-table_previous')

        # Click in the run link
        self.open_action_survey_run('action in')

        # Click on the first value
        self.selenium.find_element_by_link_text("*****@*****.**").click()

        # Modify the value of the column
        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(
            "14"
        )
        # Submit changes to the first element
        self.selenium.find_element_by_xpath(
            "(//button[@name='submit'])[1]"
        ).click()
        self.wait_for_datatable('actioninrun-data_previous')

        # Click on the second value
        self.selenium.find_element_by_link_text("*****@*****.**").click()

        # Modify the value of the column
        self.selenium.find_element_by_id("id____ontask___select_1").clear()
        self.selenium.find_element_by_id(
            "id____ontask___select_1"
        ).send_keys("15")
        # Submit changes to the second element
        self.selenium.find_element_by_xpath(
            "(//button[@name='submit'])[1]"
        ).click()
        self.wait_for_datatable('actioninrun-data_previous')

        # Click on the third value
        self.selenium.find_element_by_link_text("*****@*****.**").click()

        # Modify the value of the column
        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("16")
        # Submit changes to the second element
        self.selenium.find_element_by_xpath(
            "(//button[@name='submit'])[1]"
        ).click()
        self.wait_for_datatable('actioninrun-data_previous')

        # Click in the back link!
        self.selenium.find_element_by_link_text('Back').click()
        self.wait_for_datatable('action-table_previous')

        # Go to the table page
        self.go_to_table()

        # Assert the new values
        self.assertIn('<td class=" dt-center">14</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">15</td>',
                      self.selenium.page_source)
        self.assertIn('<td class=" dt-center">16</td>',
                      self.selenium.page_source)

        # End of session
        self.logout()
コード例 #56
0
 def selectOptipn(self, locator, text):
     select = Select(locator)
     select.select_by_visible_text(text)
コード例 #57
0
    def test_01_symbols(self):
        symbols = '!#$%&()*+,-./:;<=>?@[\]^_`{|}~'

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

        # Go to the details page
        self.access_workflow_from_home_page('sss')

        # 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
        self.selenium.find_element_by_xpath(
            "//table[@id='attribute-table']/tbody/tr/td[3]/button[2]"
        ).click()
        # Wait for the delete confirmation frame
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'modal-title'),
                                             'Confirm attribute deletion')
        )
        # Click in the delete confirm button
        self.selenium.find_element_by_xpath(
            "//div[@class='modal-footer']/button[2]"
        ).click()
        # MODAL WAITING
        self.wait_close_modal_refresh_table('attribute-table_previous')

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

        # Save and close the attribute page
        self.selenium.find_element_by_link_text('Back').click()
        # Wait for the details page
        self.wait_close_modal_refresh_table('column-table_previous')

        # 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')

        # Set the right columns to process
        select = Select(self.selenium.find_element_by_id(
            'select-column-name'))
        select.select_by_visible_text('!#$%&()*+,-./:;<=>?@[\]^_`{|}~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')
            )
        )

        select = Select(self.selenium.find_element_by_id(
            'select-key-column-name'))
        select.select_by_visible_text('sid')
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        select = Select(self.selenium.find_element_by_id(
            'select-key-column-name'))
        select.select_by_visible_text('email')
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )

        # Save action-in
        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.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(
            "//body/div[4]/div/form/button[1]/span").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.selenium.find_element_by_xpath(
            "//div[@id='table-content']/a"
        ).click()
        # Wait for paging widget
        self.wait_for_datatable('action-table_previous')

        # Edit the action out
        element = self.search_action('action_out')
        element.find_element_by_link_text("Edit").click()

        # Insert attribute
        self.selenium.find_element_by_id("select-attribute-name").click()
        Select(self.selenium.find_element_by_id(
            "select-attribute-name")).select_by_visible_text("- Attribute -")

        # Insert column name
        self.selenium.find_element_by_id("select-column-name").click()
        Select(self.selenium.find_element_by_id(
            "select-column-name")).select_by_visible_text(symbols)

        # Insert second column name
        self.selenium.find_element_by_id("select-column-name").click()
        Select(self.selenium.find_element_by_id(
            "select-column-name")).select_by_visible_text(symbols + '2')

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

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

       # Click the preview button
        self.selenium.find_element_by_xpath(
            "//div[@id='html-editor']/form/div[3]/button").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()

        # End of session
        self.logout()
コード例 #58
0
    def test_local_pgan_auto(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)

        # ------- Login Details ------------
        user = LoginUsers()
        Admin = user.user1_name
        Pwd = user.user1_password
        expadmin = user.user1_expadmin
        exppass = user.user1_exppass
        # ------ local path ------------
        paths = Paths()
        locpath = paths.Local_path
        #-------Pgan path -----------
        pgan_path = paths.Pgan_path

        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("************ Pgan Auto *****************")
        # --------Frame work--------------
        f = self.driver1.find_element_by_xpath("//img[@src='/images/tenserflow.png']")
        f.click()
        print("Selected Tensorflow")
        sleep(2)
        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(locpath)

        # ----------GPU Auto --------
        gpu = self.driver1.find_element(By.ID, 'r4')
        gpu.click()
        sleep(2)
        auto = self.driver1.find_element_by_id("r101")
        auto.click()
        sleep(2)
        print("Your selected Auto")
        # ------Screenshot-1-----------
        ss.ScreenShot(ss_path + "test_03_local_pagn_auto_setupscreen.png")
        #-----Setup screen ------------
        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("pgan")
        sleep(2)

        trinfile = self.driver1.find_element(By.ID, 'file_name')
        trfile = Select(trinfile)
        trfile.select_by_visible_text("train.py")
        sleep(2)

        # --------- Train --------------------
        train = self.driver1.find_element_by_xpath("//a[@href='#train']")
        train.click()
        sleep(2)
        textpath = self.driver1.find_element_by_id("textVal")
        textpath.clear()
        textpath.send_keys(pgan_path)
        sleep(2)
        Train = self.driver1.find_element(By.ID, 'train_id')
        Train.click()

        sleep(620)
        # ------- Gpu Usage --------------------
        gpuTime = driver1.find_elements_by_id("gputime")
        for GpuUsage in gpuTime:
            assert isinstance(GpuUsage.text, object)
            print("Gpu Usage : ", str(GpuUsage.text))
        sleep(1000)
        # --------Elapsed Time -------------------
        myElem = self.driver1.find_element_by_id("elapsedTime")
        myElem.click()
        sleep(1)
        # --------Screen shot-2 -----------
        ss.ScreenShot(ss_path + "test_03_local_pagn_auto_elapsedtime.png")
        sleep(3)
        assert isinstance(myElem.text, object)
        print("Pgan Auto -", str(myElem.text))

        for logs in driver1.get_log('browser'):
            print(logs)

        try:
            '''for elapsedTime in gettime:
                assert isinstance(elapsedTime.text, object)
                print("Pggan Auto -", str(elapsedTime.text))'''
        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))
コード例 #59
0
 def fillcountry(self, countrytxt):
     s = Select(self.country)
     s.select_by_visible_text(countrytxt)
コード例 #60
0
    driver.find_element_by_name('children[3]').send_keys('人工智能')
    driver.find_element_by_id('submit').click()
    driver.back()
    sleep(1)

    # 进入iframe
    iframe = driver.find_element_by_id('iframe-4')
    driver.switch_to.frame(iframe)

    # 点击 创建文档
    driver.find_element_by_xpath('//*[@id="menuActions"]/a').click()

    # 分类
    element = driver.find_element_by_id('module')
    modules = Select(element)
    modules.select_by_visible_text('/自动化')

    # 授权用户
    driver.find_element_by_xpath('//*[@id="users_chosen"]/ul').click()
    driver.find_element_by_xpath(
        '//*[@id="users_chosen"]/div/ul/li[1]').click()
    # 授权分组
    driver.find_element_by_id('groups1').click()
    driver.find_element_by_id('groups2').click()
    driver.find_element_by_id('groups3').click()

    # 文档类型
    types = ['typetext', 'typeurl']
    doctype = types[random.randint(0, 1)]
    # doctype = types[1]
    driver.find_element_by_id(doctype).click()