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


Python Select.is_selected方法代码示例

本文整理汇总了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)
开发者ID:try-dash-now,项目名称:idash,代码行数:104,代码来源:webgui.py


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