本文整理汇总了Python中selenium.selenium函数的典型用法代码示例。如果您正苦于以下问题:Python selenium函数的具体用法?Python selenium怎么用?Python selenium使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了selenium函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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
示例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")
示例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)))
示例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()
示例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
示例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
示例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()
示例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
示例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()
示例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)
示例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 "---------------"
示例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()
示例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()
示例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})