当前位置: 首页>>代码示例>>Python>>正文


Python Select.click方法代码示例

本文整理汇总了Python中selenium.webdriver.support.ui.Select.click方法的典型用法代码示例。如果您正苦于以下问题:Python Select.click方法的具体用法?Python Select.click怎么用?Python Select.click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.ui.Select的用法示例。


在下文中一共展示了Select.click方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _select_case

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
    def _select_case(self, role, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(role))
        time.sleep(1)

        checkbox = None
        wait_until(lambda: self._browser.find_elements_by_css_selector('.tree-node .tree-title') and True)
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        finder = re.compile(r'.*\b' + case + r'\b')
        finder_dotted = re.compile(r'.*\b' + case.replace(' ', r'\.') + r'\b')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if finder.match(elem.text) or finder_dotted.match(elem.text):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        self._browser.execute_script("$('.overview').css('left', '0')")
        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
开发者ID:pvanhorn,项目名称:openthread,代码行数:37,代码来源:harness_case.py

示例2: _select_case

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
    def _select_case(self, suite, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(suite))
        time.sleep(1)

        checkbox = None
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if elem.text.startswith(case):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not self.wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
开发者ID:MatthewCoppola4,项目名称:openthread,代码行数:33,代码来源:harness_case.py

示例3: open

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
with open('temp_2.csv', 'rb') as f:
    reader = csv.reader(f)
    for row in reader:
        sf_urls.append(''.join(row))


for no,url in enumerate(sf_urls):
    
    print no,url
    #browser.get('https://na8.salesforce.com/'+ url)
    browser.get(url)
    try:
        temp_wait = WebDriverWait(browser, 5).until(EC.presence_of_element_located((By.ID, "00N80000003Lv1c_ileinner")))
            
        #   Field : Repeat Deal
        rd = browser.find_element_by_id('00N80000003Lv1c_ileinner')
        doubled_click(rd)
        temp_wait = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, "00N80000003Lv1c")))
        select = Select(browser.find_element_by_id('00N80000003Lv1c'))
        select.select_by_value("Recommended")
        select = browser.find_element_by_name('inlineEditSave')
        select.click()
        status = 'Done'
        time.sleep(5)
    except e:
        status = 'Declined'
        time.sleep(5)
    out_table.add_row([url,status,(time.time() - start_time)])
print out_table
print("--- %s seconds ---" % (time.time() - start_time))
开发者ID:Thuruv,项目名称:vertigo,代码行数:32,代码来源:2nd.py

示例4: image_notes

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
def image_notes(sf_urls,out_table,Editorial_Fine_Print=Editorial_Fine_Print,browser=x.driver):
    for url in sf_urls:
        try:
            start_time = time.time()              
            browser.get('https://na8.salesforce.com/'+ url)

            md = browser.find_elements_by_class_name('listTitle')
            temp_wait = WebDriverWait(browser, 5).until(EC.presence_of_element_located((By.ID, "00NC0000005L5vx_ileinner")))
            buy_button = browser.find_element_by_id('00NC0000005L5vx_ileinner')
            if ''.join(re.findall('\\b\\d+\\b',md[1].text)) == buy_button.text:
                print url + '--> : Buy Button Check - Positive'
                status = 'proceeded'
                logging.debug('Total No of buy buttons Correct')
            else:
                status = 'Declined'
                sys.exit()
                logging.debug('Total No of buy buttons Wrong')
            
            #add = browser.find_element_by_xpath('//*[@id="006C0000011fvVw_00NC0000004iQvK"]/div[1]/div/div[1]/table/tbody/tr/td[2]/input')
            add = browser.find_element_by_xpath('//*[@id="00N80000003LdTG_ileinner"]')
            doubled_click(add)
            #WebbrowserWait(browser, 15).until(EC.title_contains("Edition"))
            image_notes = browser.find_element_by_id('00N80000003LdTG_ileinneredit')
            copy_old_text = (image_notes.text).encode('ascii', 'ignore')
            new_text = browser.find_element_by_id('00N80000003LdTG')
            image_notes_final = WebDriverWait(browser, 15).until(EC.presence_of_element_located((By.ID, "00N80000003LdTG")))
            new_text.send_keys(str(copy_old_text) + '\nCMS page complete, no need to remake images')
            save_image_notes = browser.find_element_by_xpath('//*[@id="InlineEditDialog_buttons"]/input[1]')    # input[1] -> Save
            #sleep(5)
            doubled_click(save_image_notes) 

            
            #   Field : Repeat Deal
            rd = browser.find_element_by_id('00N80000004hVCp_ileinner')
            doubled_click(rd)
            temp_wait = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, "00N80000004hVCp")))
            select = Select(browser.find_element_by_id('00N80000004hVCp'))
            select.select_by_value("Multi-record deal")
            
            
            #   Field : Do Not Upload

            dnup = browser.find_element_by_id('00NC0000005LicT_chkbox')
            copy_old_text = (dnup.get_attribute('title')).encode('ascii', 'ignore')
            if copy_old_text == 'Checked':
                pass
            else:
                doubled_click(dnup)
                #temp_wait = WebDriverWait(browser, 3).until(EC.presence_of_element_located((By.ID, "00NC0000005LicT")))
                browser.find_element_by_id('00NC0000005LicT').click()
         

            #   Editorial Fine Print

            if 'clearance' in (browser.title).lower():
                efprint = browser.find_element_by_id('00NC0000005MXTX_ilecell')
                doubled_click(efprint)
                #temp_wait = WebDriverWait(browser, 3).until(EC.presence_of_element_located((By.ID, "00NC0000005LicT")))
                efprint_edit_cell = browser.find_element_by_id('00NC0000005MXTX')
                en = browser.find_element_by_id('00NC0000005QFSJ_ileinner')
                if str(en.text) == 'en-US':
                    fine_print_text = Editorial_Fine_Print['fine_print_clearance_us']
                else:
                    fine_print_text = Editorial_Fine_Print['fine_print_clearance_ca']

                efprint_edit_cell.send_keys(fine_print_text)
                save_eprint = browser.find_element_by_xpath('//*[@id="InlineEditDialog_buttons"]/input[1]')
                save_eprint.click()
                
            elif 'owned' in (browser.title).lower():
                efprint = browser.find_element_by_id('00NC0000005MXTX_ilecell')
                doubled_click(efprint)
                #temp_wait = WebDriverWait(browser, 3).until(EC.presence_of_element_located((By.ID, "00NC0000005LicT")))
                efprint_edit_cell = browser.find_element_by_id('00NC0000005MXTX')
                en = browser.find_element_by_id('00NC0000005QFSJ_ileinner')
                if str(en.text) == 'en-US':
                    fine_print_text = Editorial_Fine_Print['fine_print_owned_us']
                else:
                    fine_print_text = Editorial_Fine_Print['fine_print_owned_ca']
                    
                efprint_edit_cell.send_keys(fine_print_text)
                save_eprint = browser.find_element_by_xpath('//*[@id="InlineEditDialog_buttons"]/input[1]')
                save_eprint.click()
            else:
                throws()
                

            #   CC Done
            
            cc = browser.find_element_by_id('00NC0000005Li05_ileinner')
            doubled_click(cc)
            select = browser.find_element_by_xpath('//*[@id="datePicker"]/div[2]/div/a')
            select.click()

            #   Writer Ready

            cc = browser.find_element_by_id('00N80000003Wtbs_ileinner')
            doubled_click(cc)
            select = browser.find_element_by_xpath('//*[@id="datePicker"]/div[2]/div/a')
            select.click()
#.........这里部分代码省略.........
开发者ID:Thuruv,项目名称:vertigo,代码行数:103,代码来源:app-prod.py

示例5: print

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
    for window in windows:
        driver.close()


if __name__ == "__main__":
    driver = webdriver.Chrome(executable_path="/home/wangbx/Tools/ergwave/chromedriver", service_log_path="/dev/null")
    driver.get("http://stackoverflow.com")
    time.sleep(2)

    if driver.title == "Stack Overflow":
        print("No need web login")
    elif "not available" in driver.title:
        print("Failed")
    else:
        if "edirect" in driver.page_source:
            time.sleep(5)
        elm = driver.find_element_by_name("user")
        elm.send_keys("bxwang")
        elm = driver.find_element_by_name("password")
        elm.send_keys("123456")
        elm = Select(driver.find_element_by_name("fqdn"))
        elm.select_by_visible_text("CSE")
        driver.set_page_load_timeout(3)
        elm = driver.find_element_by_name("Login")
        try:
            elm.click()
        except TimeoutException:  # which should happen
            print("Done web login")
            pass
    close(driver)
开发者ID:wangbx66,项目名称:ERGWAVE,代码行数:32,代码来源:ergwave.py

示例6: webgui

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
class webgui(dut, object):
    obj     = None
    path = None
    common_wait_interval = 1
    old_retry = 5
    driver = None

    def quit(self):
        if self.driver:
            self.driver.quit()
    def __init__(self, name, attr =None,logger=None, logpath= None, shareData=None):
        #try:
        dut.__init__(self, name,attr,logger,logpath,shareData)
        self.log_file =self.logfile


        binary = None
        if FireFox:
            binary_path = './selenium/webdriver/firefox/'

            profile_path =None
            profile =None# webdriver.FirefoxProfile(profile_path)
            #profile = webdriver.FirefoxProfile()
            a = FirefoxBinary()._get_firefox_start_cmd()
            #print(a, 'firefox file!!!!!!!!!!!!!!!!!!')
            if os.path.exists(binary_path):
                binary = FirefoxBinary(a)
                profile = webdriver.FirefoxProfile(binary_path)

            self.driver= webdriver.Firefox(firefox_binary=binary,firefox_profile=profile)

            self.driver.log_file= self.logfile
        else:
            self.driver = webdriver.Chrome()
            #webdriver.Chrome.__init__(self)
        #webdriver.Firefox.__init__(self,firefox_profile=profile)#, firefox_profile=profile, firefox_binary=)#

        #except:
        #    webdriver.Chrome.__init__(self)
            #webdriver.Firefox.__init__(self)

        if self.attribute.has_key('INTERVAL'):
            self.common_wait_interval = self.attribute['INTERVAL']
            time.sleep(0.5)
        else:
            self.common_wait_interval = 1

    @retry
    def set_retry(self, retry_max):
        global g_retry_counter
        self.old_retry = g_retry_counter
        g_retry_counter = retry_max
    @retry
    def restore_retry(self):
        global g_retry_counter
        g_retry_counter =self.old_retry
    @retry
    def xfind(self, path, type):
        if path is not None:
            self.path = path
        if str(type).lower() == 'xpath':
            function = self.driver.find_element_by_xpath
        elif str(type).lower() == 'name':
            function = self.driver.find_element_by_name
        elif str(type).lower() == 'text':
            function = self.driver.find_element_by_link_text
        elif str(type).lower() == 'id':
            function = self.driver.find_element_by_id
        self.obj = function(self.path)
        return  self.obj
    @retry
    def xsend(self, cmd, path=None, type_by= 'xpath'):
        element = self.xfind(path, type_by)
        element.send_keys(cmd)
        #time.sleep(1)
    @retry
    def xclick( self, xpath=None, type_by='xpath'):
        element = self.xfind(xpath, type_by)
        element.click()
        self.sleep(1)
    @retry
    def xclear( self, xpath=None, type_by='xpath'):
        element = self.xfind(xpath, type_by)
        element.clear()
        #time.sleep(1)
    @retry
    def xrefill(self, data, xpath, type_by = 'xpath'):
        element = self.xfind(xpath, type_by)
        element.clear()
        element.send_keys(data)
    @retry
    def xselect(self, value, xpath=None, type_by='xpath'):
        self.obj = Select(self.xfind(xpath, type_by))
        self.obj.select_by_visible_text(value)
        self.sleep(1)
    @retry
    def xget(self,url=None):
        if url is not None:
            self.curr_url = url
        self.driver.get(self.curr_url)
#.........这里部分代码省略.........
开发者ID:try-dash-now,项目名称:idash,代码行数:103,代码来源:webgui.py

示例7: SearchEvent

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
def SearchEvent(driver,noindex,url):
	
	# Firefox configuration for BrowserStack
	#desired_cap = {'browser': 'Firefox', 'browser_version': '35.0', 'os': 'Windows', 'os_version': '7', 'resolution': '1024x768'}
	#driver = webdriver.Remote(
	   #command_executor='http://wwedigital:[email protected]:80/wd/hub',
	   #desired_capabilities=desired_cap)
	# Firefox configuration for local
	driver = webdriver.Firefox()
	driver.delete_all_cookies()
	driver.get(url)
	keywordReportVar=""
	keywordReportVar2=""
	keywordReportVar3=""	
	AllTestCasedata=""
	status=""
	status1=""
	# Press Key 'ESCAPE'
	webElements = driver.find_element_by_xpath("//div[@id='live_events_1153']/div/div/div/div[2]/div/div/div/select").send_keys(Keys.ESCAPE)
	print "Escape"
	# Select event in drop-down
	webElements = Select(driver.find_element_by_xpath("//div[@id='live_events_1153']/div/div/div/div[2]/div/div/div/select"))
	webElements.select_by_visible_text('Raw')
	# Capture screen-shot
	strLink = report.CaptureSnapshot(driver,"Event.png")
	keywordReportVar+=report.keywordReportMethod(True,1,"Selecting the RAW event","Event has been selected",strLink,"Windows")


	time.sleep(2)

	webElements = driver.find_element_by_xpath("//div[@id='live_events_1153']/div/div/div/div[2]/div[3]/div[4]/a")
	webElements.click()
	# Capture screen-shot and fetching data from UI
	strLink = report.CaptureSnapshot(driver,"SearchEvent.png")
	keywordReportVar2+=report.keywordReportMethod(True,1,"Click on search event","Event has been selected",strLink,"Windows")
	
	
	time.sleep(5)
	
	FetchedText = driver.find_element_by_xpath("//*[@id='live_events_1153']/div/div/div/div[3]/span[1]/a").get_attribute("title")
	FetchedText2 = driver.find_element_by_xpath("//*[@id='live_events_1153']/div/div/div/div[4]/span[1]/a").get_attribute("title")
#	FetchedText3 = driver.find_element_by_xpath("//*[@id='live_events_1153']/div/div/div/div[5]/span[1]/a").get_attribute("title")
		
	print FetchedText
	print FetchedText2
#	print FetchedText3

	time.sleep(2)
	# Verifying data from UI
	if FetchedText.find("Raw", 0) > -1 and FetchedText2.find("Raw", 0) > -1 :
		strMsg = "User is able to search any event"
		status1=True
		status=True
	else :
		strMsg = "User is not able to search the event"
		status=False
		status1=False	

		
	path= "/wsx/"+'EventSearchResult.png'   
	print path
	driver.save_screenshot(htmlFolderPath+path)

	print htmlFolderPath
		
	keywordReportVar3+=report.keywordReportMethod(status1,1,"Event Search Scenario",strMsg,path,"Windows")    
	#driver.find_element_by_css_selector("a.bgimg.right").click()
	# Wait for 5 seconds
	time.sleep(2)
	# Adding report in html formate
	TestCaseReportVar=report.testcaseMethod(7,"Event Search",status)
	AllTestCasedata=TestCaseReportVar+keywordReportVar+keywordReportVar2+keywordReportVar3+"</tbody></table></div>"
	return AllTestCasedata
	driver.quit()
开发者ID:ritesh19july,项目名称:FuntionalScript,代码行数:76,代码来源:Event_Search.py

示例8:

# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import click [as 别名]
time.sleep(SLEEP_SECS)
for key,value in shipping_info_next.iteritems():
	ele_selector = key
	ele = driver.find_element_by_id(ele_selector)
	ele.send_keys(value)

#
shipping_info_next = {
	'speed' : 'speed-std',
}

time.sleep(SLEEP_SECS)
for key,value in shipping_info_next.iteritems():
	ele_selector = key
	ele = driver.find_element_by_id(value)
	ele.click()

#click add to cart
time.sleep(SLEEP_SECS)
ele_number = 0
add_to_cart_selector = "btn-large"
add_to_cart_elements = driver.find_elements_by_class_name(add_to_cart_selector)
add_to_cart_elements[ele_number].click()


#billing
#
billing_info_ids = {
	'name' : 'Kevin Owocki',
	'cc-num' : '4242424242424242',
	'cvc' : '123',
开发者ID:owocki,项目名称:selenium-experiments,代码行数:33,代码来源:test_that_stores_working.py


注:本文中的selenium.webdriver.support.ui.Select.click方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。