• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python selenium.selenium函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中selenium.selenium函数的典型用法代码示例。如果您正苦于以下问题:Python selenium函数的具体用法?Python selenium怎么用?Python selenium使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: setUp3

def setUp3(self):
        tp = tParams.GetParams()
        
        if tp.place.find("sauce") > -1:
            
            self.verificationErrors = []
            self.selenium = selenium(ct.DOMAIN, ct.PORT,
                                    "{\"username\": \"" + ct.USER_NAME + 
                                    "\",\"access-key\":\"" + ct.ACCESS_KEY + 
                                    "\",\"browser\": \"" + tp.test_browser + 
                                    "\",\"job-name\":\"" + self.__class__.__name__ + 
                                    "\",\"max-duration\":\"" + ct.MAX_DURATION +
                                    "\",\"record-video\":\"" + ct.RECORD_TEST + 
                                    "\",\"os\":\"" + ct.OS + 
                                    "\"}", 
                                    tp.run_domain)
            self.selenium.start()
        else:
            if tp.place.find("local") > -1  :
                self.verificationErrors = []
                tp = tParams.GetParams()
            if tp.test_browser.find("*firefox"):
                tp.test_browser = tParams.GetParams().test_browser
            if tp.run_domain.find("http://issuu.com"):
                tp.run_domain = tParams.GetParams().run_domain
            self.selenium = selenium("localhost", 4444, tp.test_browser, tp.run_domain)
            self.selenium.start()
开发者ID:slashsorin,项目名称:auto-fe-test,代码行数:27,代码来源:MyUtilities.py


示例2: create

    def create(self):
        """
         Uses a driver specified by the 'SELENIUM_DRIVER' environment variable,
         and run the test against the domain specified in 'SELENIUM_URL' system property or the environment variable.
         If no variables exist, a local Selenium driver is created.
        """

        if 'SELENIUM_STARTING_URL' not in os.environ:
            startingUrl = "http://saucelabs.com"
        else:
            startingUrl = os.environ['SELENIUM_STARTING_URL']

        if 'SELENIUM_DRIVER' in os.environ and 'SELENIUM_HOST' in os.environ and 'SELENIUM_PORT' in os.environ:
            parse = ParseSauceURL(os.environ["SELENIUM_DRIVER"])
            driver = selenium(os.environ['SELENIUM_HOST'], os.environ['SELENIUM_PORT'], parse.toJSON(), startingUrl)
            driver.start()

            if parse.getMaxDuration() != 0:
                driver.set_timeout(parse.getMaxDuration())

            wrapper = Wrapper(driver, parse)
            wrapper.dump_session_id()
            return wrapper
        else:
            driver = selenium("localhost", 4444, "*firefox", startingUrl)
            driver.start()
            return driver
开发者ID:Tallisado,项目名称:SeleniumFactory-for-Python,代码行数:27,代码来源:SeleniumFactory.py


示例3: setUp

    def setUp(self):
        configuration = NySeleniumConfig()
        self.verificationErrors = []
        supported_browsers = [ '*firefox', '*mock', '*firefoxproxy',
                             '*pifirefox', '*chrome', '*iexploreproxy',
                             '*iexplore', '*firefox3', '*safariproxy',
                             '*googlechrome', '*konqueror', '*firefox2',
                             '*safari', '*piiexplore', '*firefoxchrome',
                             '*opera', '*iehta', '*custom']
        browsers = configuration.data['browsers'].split(",")

        if(browsers[0] == '*all'):
            for browser in supported_browsers:
                self.selenium = selenium("localhost", 5555, browser,\
                                         configuration.data['site'])
                self.selenium.start()
        elif((len(browsers) == 1) and (browsers[0] in supported_browsers)):
            self.selenium = selenium("localhost", 5555, browsers[0],\
                                         configuration.data['site'])
            self.selenium.start()
        elif((len(browsers) > 1)):
            for browser in browsers:
                if browser in supported_browsers:
                    import pdb;
                    pdb.set_trace()
                    print browser
                    self.selenium = selenium("localhost", 5555, browsers[0],\
                                         configuration.data['site'])
                    self.selenium.start()
        #elif(len(browsers) == 0):
        #    self.selenium = selenium("localhost", 5555, "*firefox",\
        #                                 configuration.data['site'])
        #    self.selenium.start()
        else:
            self.verificationErrors.append("Could not start selenium instance")
开发者ID:bogtan,项目名称:naaya.selenium,代码行数:35,代码来源:NySeleniumTest.py


示例4: _start_rc_client

def _start_rc_client(item):
    if item.sauce_labs_credentials_file:
        settings = _get_common_sauce_settings(item)
        settings.update({'username': item.sauce_labs_credentials['username'],
                         'access-key': item.sauce_labs_credentials['api-key'],
                         'os': item.platform,
                         'browser': item.browser_name,
                         'browser-version': item.browser_version})
        TestSetup.selenium = selenium('ondemand.saucelabs.com', '80',
                                      json.dumps(settings),
                                      TestSetup.base_url)
    else:
        browser = item.environment or item.browser
        TestSetup.selenium = selenium(item.host, str(item.port), browser, TestSetup.base_url)

    if item.config.option.capture_network:
        TestSetup.selenium.start("captureNetworkTraffic=true")
    else:
        TestSetup.selenium.start()

    if item.sauce_labs_credentials_file:
        _capture_session_id(item, _debug_path(item))

    TestSetup.selenium.set_timeout(TestSetup.timeout)
    TestSetup.selenium.set_context(".".join(_split_class_and_test_names(item.nodeid)))
开发者ID:bebef1987,项目名称:pytest-mozwebqa,代码行数:25,代码来源:mozwebqa.py


示例5: setUp

 def setUp(self):
     self.verificationErrors = []
     self.seleniumN = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumN.start()
     self.seleniumE = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumE.start()
     self.seleniumS = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumS.start()
     self.seleniumW = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumW.start()
开发者ID:event,项目名称:we-bridge,代码行数:10,代码来源:SitBidPlay.py


示例6: shut_down_selenium_server

def shut_down_selenium_server(host='localhost', port=4444):
    """Shuts down the Selenium Server.

    `host` and `port` define where the location of Selenium Server.

    Does not fail even if the Selenium Server is not running.
    """
    try:
        selenium(host, port, '', '').shut_down_selenium_server()
    except socket.error:
        pass
开发者ID:robotframework,项目名称:SeleniumLibrary,代码行数:11,代码来源:__init__.py


示例7: sel

 def sel(self):
     
     if hasattr(self, '_sel'):
         return self._sel
         
     if self.login_mode == 'basic':
         self._sel = selenium(self.sel_host, self.sel_port, self.sel_browser, 
                              'http://%s:%[email protected]%s:%s/'%(self.username, self.password, self.ip, self.port))
     else:
         self._sel = selenium(self.sel_host, self.sel_port, self.sel_browser, 'http://%s/'%self.ip)
     self._sel.start()
     
     return self._sel
开发者ID:ogreworld,项目名称:SeleniumCtrl,代码行数:13,代码来源:selenium_operator.py


示例8: setUp

 def setUp(self):
     """Make the selenium connection"""
     TestCase.setUp(self)
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*firefox",
                              "http://localhost:8000/")
     self.selenium.start()
开发者ID:AthinaB,项目名称:synnefo,代码行数:7,代码来源:tests.py


示例9: __init__

 def __init__(self):
     self.PAGE_LOAD_TIMEOUT = 1000
     #self.url = 'http://apps.isiknowledge.com'
     self.url = C.START_URL  
     self.br = selenium("localhost", 4444, "*chrome", self.url)
     self.FILE_SAVING_TIME = 1.0   # seconds to wait before attempting to read downloaded files
     self.SKIP_TIME = 0.5    # seconds to wait before re-attempting to read downloaded files
开发者ID:ttrikalin,项目名称:citation_graphs,代码行数:7,代码来源:sel_isi.py


示例10: setUp

 def setUp(self):
     self.toolBox = self.getGlbToolbox()
     self.selenium = selenium(
         "localhost", 4444, "*firefox", "https://stage.ariasystems.net/webclients/dreamworksPay/Handler.php"
     )
     self.selenium.start()
     self.selenium.window_maximize()
开发者ID:ramyamango123,项目名称:test,代码行数:7,代码来源:getMasterBillingAccount.py


示例11: setUp

 def setUp(self):
     self.selenium = selenium(ConnectionParameters.server, 
                             ConnectionParameters.port,
                             ConnectionParameters.browser, 
                             ConnectionParameters.baseurl)
     self.selenium.start()
     self.selenium.set_timeout(ConnectionParameters.page_load_timeout)
开发者ID:josmas,项目名称:Addon-Tests,代码行数:7,代码来源:test_themes.py


示例12: __init__

    def __init__(self):
        CrawlSpider.__init__(self)
	print "szlibspider start"
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*firefox /usr/lib/firefox/firefox", "http://www.szlib.gov.cn/libraryNetwork/selfLib/id-5.html")
	ffdriver = Firefox()
	self.selenium.start(driver=ffdriver)
#	self.selenium.start()


        sel = self.selenium
#        sel.open("http://www.szlib.gov.cn/libraryNetwork/selfLib/id-5.html")
        ffdriver.get("http://www.szlib.gov.cn/libraryNetwork/selfLib/id-5.html")
	WebDriverWait(ffdriver,30).until(ajax_complete, "Timeout waiting page to load")	

        #Wait for javscript to load in Selenium
#        time.sleep(20)
#	sel.wait_for_condition("condition by js", 20000);
#	print "ul/li visible? %s" % sel.is_element_present("//ul[@class='servicepointlist']")

	elements = ffdriver.find_elements_by_xpath("//ul[@class='servicepointlist']/li[@class='item']")
	for element in elements[:5]:
		print "%s" % element.find_element_by_class_name("num").text
		print "%s" % element.find_element_by_class_name("title").text
		print "%s" % element.find_element_by_class_name("text").text
		print "---------------"
开发者ID:kingcent,项目名称:szlibspider,代码行数:26,代码来源:szlibspider-ok.py


示例13: full_scrape

def full_scrape(config):
    print("Updating constant entries...")
    update_constants()

    print("Beginning scrape job...")

    # Create a new instance of Selenium
    s = selenium("localhost", 4444, "*chrome", "https://sso.queensu.ca/amserver/UI/Login")
    s.start()
        
    s.set_timeout(config.timeout_milliseconds)

    #save our useful stuff to pass around
    tools = ScraperTools(s, config)

    #get to a browsable state
    login_helper.navigate_to_course_catalog(tools)

    #Go through the pages for each letter in the course catalogue

    for letter in config.subject_letters:
        subject_helper.drill_subjects_for_letter(letter, tools)

    print("Completed scrape job")

    s.stop()
开发者ID:uniphil,项目名称:QcumberD,代码行数:26,代码来源:__init__.py


示例14: setUpHierarchy

 def setUpHierarchy(browser = "*chrome", 
                    path = "", 
                    ipaddr = "localhost", 
                    ipport = 4444, 
                    webURL = "http://127.0.0.1:8000/"):
     """
         This method would typically only be run once it will create a
         Selenium instance and then start it.
         
         This is a static method with the idea that the properties created
         in this method are shared amongst all subclasses. That is:
         SahanaTest.selenium and SahanaTest.action
     """
     if  (SahanaTest.ipaddr != ipaddr) or (SahanaTest.ipport != ipport) or (SahanaTest.browser != browser) or (SahanaTest.webURL !=  webURL):
         SahanaTest._seleniumCreated = False
     # Only run once
     if not SahanaTest._seleniumCreated:
         if browser == "*custom":
             browser += " %s" % path
         print "selenium %s %s %s %s" % (ipaddr, ipport, browser, webURL)
         SahanaTest.ipaddr = ipaddr
         SahanaTest.ipport = ipport
         SahanaTest.browser = browser
         SahanaTest.webURL =  webURL
         SahanaTest.selenium = selenium(ipaddr, ipport, browser, webURL)
         SahanaTest.action = actions.Action(SahanaTest.selenium)
         SahanaTest._seleniumCreated = True
     if SahanaTest.selenium.sessionId == None:
         SahanaTest.selenium.start()
开发者ID:AnithaT,项目名称:eden,代码行数:29,代码来源:sahanaTest.py


示例15: test_validNewInfo

    def test_validNewInfo(self):
        '''Valid new account information -- TC2'''
        self.selenium = selenium("localhost", 4444, "*firefox", "https://stage.ariasystems.net/webclients/dreamworksPay/Handler.php")
        self.selenium.start()
        self.selenium.window_maximize()
        username, result1 = self.toolBox.registerNewUsername()
        self.assertTrue('user' in result1, "XML from register does not contain user")
        gameAcctId = self.toolBox.getGameIdFromUser(username)
        id = result1['user']['id']
        firstName = 'Tester'
        lastName = 'Dummy'
        billingType = '1'
        address1 = '123 Fake Street'
        city = 'San Mateo'
        state = 'CA'
        country = 'US'
        zipCode = '94403'
        gameUrl = 'http://gazillion.com'
        clientIpAddress = '192.168.1.1'
        result2 = self.toolBox.createBillingAcct(id,gameAcctId,billingType,clientIpAddress,planId='10003936',firstName=firstName,lastName=lastName,
                                                      address1=address1,city=city,state=state,country=country,zipCode=zipCode,gameUrl=gameUrl)
        self.assertTrue('account' in result2, result2)
        billingId = result2['account']['accountId']
        sessionId = result2['account']['inSessionID']
        flowId = result2['account']['flowID']
        self.ariaHostedPage(sessionId, flowId)
        self.selenium.close()
        self.selenium.stop()

        result = self.toolBox.getChildBillingAccounts(id)
        self.assertTrue(result.httpStatus() == 499,\
                        "http status code: " + str(result.httpStatus()))    
        self.failureCheck(result, ['There are no child billing accounts for this user', '16035'])
        self.infoFailCheck(result, id)
        self.toolBox.scriptOutput("getChildBillingAccounts new account structure account", {"Gazillion Id": id, "childBillingAccountId": billingId})
开发者ID:ramyamango123,项目名称:test,代码行数:35,代码来源:getChildBillingAccounts.py


示例16: __init__

    def __init__(self, host,
                       port,
                       start_cmd,
                       load_timeout,
                       webpage_language,
                       webpage_currency,
                       webpage_usrplace,
                       departure_month,
                       departure_year,
                       output_encoding):

        print('Initializing selenium...')
        
        self.host             = host
        self.port             = port
        self.start_cmd        = start_cmd
        self.load_timeout     = load_timeout
        self.webpage_language = webpage_language
        self.webpage_currency = webpage_currency
        self.webpage_usrplace = webpage_usrplace
        self.departure_month  = departure_month
        self.departure_year   = departure_year
        self.output_encoding  = output_encoding

        self.num_of_flights = -1

        self.browser = selenium(self.host, self.port, self.start_cmd, self.root_url)
开发者ID:andre-wojtowicz,项目名称:skyscanner-crawler,代码行数:27,代码来源:SeleniumWrapper.py


示例17: setUp

 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost",
             4444,
             "*chrome",
             "http://localhost:8000/")
     self.selenium.start()
开发者ID:tranvictor,项目名称:truongnha,代码行数:7,代码来源:selenium_tests.py


示例18: start_browser

def start_browser(browser, html_out):
    if browser == "chrome":
        # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
        # installing Chrome. Also note that the build bot runs have a different path
        # from a normal user -- check the build logs.
        return selenium.webdriver.Chrome()
    elif browser == "ff":
        profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile()
        profile.set_preference("dom.max_script_run_time", 0)
        profile.set_preference("dom.max_chrome_script_run_time", 0)
        return selenium.webdriver.Firefox(firefox_profile=profile)
    elif browser == "ie" and platform.system() == "Windows":
        return selenium.webdriver.Ie()
    elif browser == "safari" and platform.system() == "Darwin":
        # TODO(efortuna): Ensure our preferences (no pop-up blocking) file is the
        # same (Safari auto-deletes when it has too many "crashes," or in our case,
        # timeouts). Come up with a less hacky way to do this.
        backup_safari_prefs = os.path.dirname(__file__) + "/com.apple.Safari.plist"
        if os.path.exists(backup_safari_prefs):
            shutil.copy(backup_safari_prefs, "/Library/Preferences/com.apple.Safari.plist")
        sel = selenium.selenium("localhost", 4444, "*safari", "file://" + html_out)
        try:
            sel.start()
            return sel
        except socket.error:
            print "ERROR: Could not connect to Selenium RC server. Are you running" + " java -jar selenium-server-standalone-*.jar? If not, start " + "it before running this test."
            sys.exit(1)
    else:
        raise Exception("Incompatible browser and platform combination.")
开发者ID:hyamamoto,项目名称:dart,代码行数:29,代码来源:run_selenium.py


示例19: refreshSelenium

def refreshSelenium() :
  global sel
  if sel :
    sel.stop()
    sel = None
  sel = selenium("localhost", 4444, "*firefox", getWebRoot())
  sel.start()
开发者ID:blundeln,项目名称:drool,代码行数:7,代码来源:seleniumtest.py


示例20: setUp

 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("ondemand.saucelabs.com", 
                              80, 
                              "{\"username\": \"issuu\",\"access-key\":\"23a5b32a-6ab8-4866-8f1d-9a13c98348c2\",\"browser\": \"firefox\",\"browser-version\":\"18\",\"job-name\":\"TestAbout\",\"max-duration\":1800,\"record-video\":true,\"user-extensions-url\":\"\",\"os\":\"Windows 2012\"}", 
                              "http://issuu.com/")
     self.selenium.start()
开发者ID:slashsorin,项目名称:auto-fe-test,代码行数:7,代码来源:aaaTestAboutReplica.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python webserver.SimpleWebServer类代码示例发布时间:2022-05-27
下一篇:
Python util.find_element函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap