本文整理汇总了Python中selenium.webdriver.support.ui.Select.is_selected方法的典型用法代码示例。如果您正苦于以下问题:Python Select.is_selected方法的具体用法?Python Select.is_selected怎么用?Python Select.is_selected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.ui.Select
的用法示例。
在下文中一共展示了Select.is_selected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: webgui
# 需要导入模块: from selenium.webdriver.support.ui import Select [as 别名]
# 或者: from selenium.webdriver.support.ui.Select import is_selected [as 别名]
#.........这里部分代码省略.........
#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)
self.sleep(1)
@retry
def have_text(self, exp_txt, path, type_by = 'xpath'):
try:
elem = self.xfind(path, type_by)
if elem.text.find(exp_txt)!=-1:
return True
else:
return False
except Exception as e:
return False
def closeSession(self):
super(webgui,self).closeSession()
self.quit()
def xcheck(self, xpath=None, type_by='xpath'):
self.obj = self.xfind(xpath, type_by)
if not self.obj.is_selected():
self.obj.click()
self.sleep(1)
def xuncheck(self, xpath=None, type_by='xpath'):
self.obj = self.xfind(xpath, type_by)
if self.obj.is_selected():
self.obj.click()
self.sleep(1)
def xswitch_2_pop(self,):
browser = self.driver
parent_h = browser.current_window_handle
# click on the link that opens a new window
handles = browser.window_handles # before the pop-up window closes
handles.remove(parent_h)
browser.switch_to.window(handles.pop())
# do stuff in the popup
# popup window closes
browser.switch_to.window(parent_h)