本文整理汇总了Python中splinter.browser.Browser类的典型用法代码示例。如果您正苦于以下问题:Python Browser类的具体用法?Python Browser怎么用?Python Browser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Browser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: analyze
def analyze(self):
project_modules = self.get_project_modules()
project_settings = self.project.source + self.project_root_path + "/settings.py"
TEST_RUNNER = 'TEST_RUNNER = "django_nose.NoseTestSuiteRunner"'
TESTS_APPS = "TESTS_APPS = ('django_nose',)"
NOSE_ARGS = ['--quiet', "-sd", '--nologcapture', '--with-coverage', '--cover-erase', '--cover-html', '--cover-html-dir=' + self.project.source + self.project_root_path, '--with-spec', '--spec-color']
MODULES = ["--cover-package=" + module for module in project_modules]
NOSE_ARGS.extend(MODULES)
NOSE_ARGS = "NOSE_ARGS = " + str(NOSE_ARGS)
settings_file = open(project_settings, "a")
settings_file.write(TEST_RUNNER + "\n")
settings_file.write(TESTS_APPS + "\n")
settings_file.write(NOSE_ARGS + "\n")
settings_file.close()
os.system("python " + self.project.source + self.project_root_path + "/manage.py test")
browser = Browser("zope.testbrowser")
browser.visit("file://" + settings.PROJECT_ROOT + "/" + self.project.source + self.project_root_path + "/index.html")
percent = browser.find_by_css("#index tfoot tr .right").text
self._remove_extracted_code()
return int(percent.replace("%", ""))
开发者ID:tarsisazevedo,项目名称:djangodash2011,代码行数:28,代码来源:analyzer.py
示例2: __init__
def __init__(self, browser_name, execute_path=None):
if execute_path is None:
self.__browser = Browser(browser_name, fullscreen=True)
self.__quit = False
else:
self.__browser = Browser(browser_name, executable_path=execute_path, fullscreen=True)
self.__quit = False
开发者ID:ikewang,项目名称:WebTester,代码行数:7,代码来源:test_engine.py
示例3: main
def main():
br = Browser('chrome')
br.visit(URL)
sleep(3)
if br.is_text_present('Connection', wait_time=7):
br.fill('login', '...')
br.fill('password', '...')
br.find_by_css('#logonForm_connect_button').first.click()
开发者ID:ThePenguin1140,项目名称:jabbapylib,代码行数:8,代码来源:splinter_wifi.py
示例4: browser_can_change_user_agent
def browser_can_change_user_agent(self, webdriver):
from splinter.browser import Browser
browser = Browser(driver_name=webdriver, user_agent="iphone")
browser.visit(EXAMPLE_APP + "useragent")
result = 'iphone' in browser.html
browser.quit()
return result
开发者ID:SergioJorge,项目名称:splinter,代码行数:8,代码来源:test_browser.py
示例5: test_webdriverchrome_should_be_deprecated
def test_webdriverchrome_should_be_deprecated(self):
with warnings.catch_warnings(record=True) as warnings_list:
warnings.simplefilter('default')
from splinter.browser import Browser
browser = Browser('webdriver.chrome')
browser.quit()
warning_message = warnings_list[0].message.args[0]
assert_equals("'webdriver.chrome' is deprecated, use just 'chrome'", warning_message)
开发者ID:thiagocaiubi,项目名称:splinter,代码行数:8,代码来源:test_browser.py
示例6: main
def main():
br = Browser('chrome')
br.visit(URL)
sleep(3)
if br.is_text_present("Remember me", wait_time=7):
br.fill('username', NAME)
br.fill('password', PASSWORD)
br.execute_script('javascript:savesettings()')
开发者ID:pratik98,项目名称:pythonscripts,代码行数:8,代码来源:tikona_login.py
示例7: main
def main():
browser = Browser()
browser.visit(url)
f = open("/tmp/source.html", "w") # save the source in a file
print >>f, browser.html
f.close()
browser.quit()
print '__END__'
开发者ID:ThePenguin1140,项目名称:jabbapylib,代码行数:10,代码来源:splinter_headless.py
示例8: login
def login(url, brower_name):
"""log in"""
print "Executing login"
browser = Browser(driver_name=brower_name)
while datetime.now().second < 50:
print datetime.now().second
browser.visit(url)
button = browser.find_by_id("ContentPlaceHolder1_hlOfferAlertAA")
if button:
button.click()
else:
print "not found"
开发者ID:TimeArrow001,项目名称:solution,代码行数:12,代码来源:DailyGetaways2016.py
示例9: get_fuel
def get_fuel(preco_alcool, preco_gasolina, consumo_alcool, consumo_gasolina, kilometragem, tanque):
"Faz o srap do resultado do simplex no phpsimplex.com"
browser = Browser("zope.testbrowser")
URL = """http://www.phpsimplex.com/simplex/page2.php?objetivo=min&Submit=Continuar&restricciones=3&variables=2&l=es&x1=%(preco_alcool)f&x2=%(preco_gasolina)f&r11=%(consumo_alcool)f&r12=%(consumo_gasolina)f&desigualdad1=1&y1=%(kilometragem)f&r21=1&r22=1&desigualdad2=-1&y2=%(tanque)f&r31=-0.2&r32=1&desigualdad3=1&y3=0"""
print URL % locals()
browser.visit(URL % locals())
browser.click_link_by_partial_href("solucion2.php")
html = BeautifulSoup(browser.html)
text = ""
try:
text = html.findAll("p")[2].getText()
# rgx = re.compile('\\d+\\.*\\d*')
# rgx = re.compile('\\d+(?:\\.\\d*)*')
# results = rgx.findall(text)
if text.count("X1 = 0"):
print "X1=0"
# rgx = re.compile('\\d+\\.\\d+')
rgx = re.compile("\\d+\\.*\\d*")
results = rgx.findall(text)
return {"custo_total": Decimal(results[0]), "vol_alcool": 0, "vol_gasolina": Decimal(results[1])}
elif text.count("X2 = 0"):
print "X2=0"
rgx = re.compile("\\d+\\.\\d+")
results = rgx.findall(text)
return {"custo_total": Decimal(results[0]), "vol_alcool": Decimal(results[1]), "vol_gasolina": 0}
else:
rgx = re.compile("\\d+\\.\\d+")
results = rgx.findall(text)
return {
"custo_total": Decimal(results[0]),
"vol_alcool": Decimal(results[1]),
"vol_gasolina": Decimal(results[2]),
}
except IndexError:
vol_alcool = 0
vol_gasolina = kilometragem / consumo_gasolina
custo_total = vol_gasolina * Decimal(preco_gasolina)
print "fuuuu"
return {
"custo_total": Decimal(custo_total),
"vol_alcool": Decimal(vol_alcool),
"vol_gasolina": Decimal(vol_gasolina),
}
开发者ID:andre2101,项目名称:fuel-control,代码行数:50,代码来源:php_simplex.py
示例10: splinter
def splinter(brow,url,id,pwd):
browser = Browser(brow)
#login 126 email websize
browser.visit(url)
#wait web element loading
time.sleep(5)
#fill in account and password
browser.find_by_id('idInput').fill(id)
browser.find_by_id('pwdInput').fill(pwd)
#click the button of login
browser.find_by_id('loginBtn').click()
开发者ID:userwxb,项目名称:card,代码行数:11,代码来源:web.py
示例11: load_tests
def load_tests(loader, tests, ignore):
global browser
browser = Browser("chrome")
browser.wait_time = 1
for test_path in filter(lambda path: path.endswith(".rst"), os.listdir("docs")):
tests.addTests(doctest.DocFileSuite(os.path.join("docs", test_path),
globs={
"rajesh": rajesh,
"browser": browser,
"start_rajesh": start_rajesh,
"stop_rajesh": stop_rajesh,
},
)
)
return tests
开发者ID:angelonuffer,项目名称:Rajesh,代码行数:15,代码来源:run_tests.py
示例12: form_fill
def form_fill(user, form):
display = Display(visible=0, size=(800, 600))
display.start()
if form.email != {}:
st = emailFill(user, form)
email_send("Software Internship Application",st,[form.email['email'], user.getField(2)],attachment=user.getField(6))
return
browser = Browser()
browser.visit(form.url)
if form.greenHouseResume:
string = """$("#application_form").append('<input type="hidden" id="resume_url" name="job_application[resume_url]" value=""" + '"' + user.getField(6.1) + '"' + """><input type="hidden" id="resume_url_filename" name="job_application[resume_url_filename]" value="resume.pdf">')"""
browser.execute_script(string)
def doClicks(): #partial_htmls being dealt with
for ele in form.html_button_clicks:
browser.find_link_by_partial_href(ele)[0].click()
def fillField():
for ele, tple in form.Fill_Fields.iteritems():
browser.fill(ele,user.getField(tple[0]))
def attachField():
for ele, field in form.Attach_Fields.iteritems():
browser.attach_file(ele,os.getcwd() + "/" + user.getField(field))
def dropDownField():
for ele, index in form.Drop_Down_Fields.iteritems():
browser.execute_script('document.getElementById("' + ele + '")[' + str(index) + '].selected=true')
def dropDownHelper():
for ele,index in form.Drop_Down_Fields_Helper.iteritems():
browser.execute_script('document.getElementsByTagName("'+ele+'")['+str(index)+'].selected=true')
def checkBoxes():
for ele in form.CheckBoxes:
browser.execute_script('document.getElementById("' + ele + '").checked=true')
def doJS():
for ele in form.extraJavaScript:
browser.execute_script(ele)
def doJSHelp():
for ele, index in form.extraJSHelper.iteritems():
browser.execute_script('document.getElementById("' + ele +'").value = "'+ user.getField(index) +'";')
def submitJS():
for ele in form.submitJS:
browser.execute_script(ele)
doClicks()
fillField()
attachField()
dropDownField()
dropDownHelper()
checkBoxes()
doJS()
doJSHelp()
submitJS()
if not form.submitJS:
browser.execute_script('document.getElementsByClassName("' + form.finalSubmit + '")[document.getElementsByClassName("' + form.finalSubmit + '").length-1].click()')
time.sleep(10)
browser.quit()
display.stop()
开发者ID:crazydreamer,项目名称:jobvite2.0,代码行数:53,代码来源:form.py
示例13: main
def main():
from splinter.browser import Browser
browser = Browser()
browser.visit('http://google.com')
browser.fill('q', 'splinter - python acceptance testing for web applications')
browser.find_by_css('.lsb').first.click()
if browser.is_text_present('splinter.cobrateam.info'):
print "Yes, the official website was found!"
else:
print "No, it wasn't found... We need to improve our SEO techniques"
#browser.execute_script("var win = window.open(); win.document.write('<html><head><title>Generated HTML of ' + location.href + '</title></head><pre>' + document.documentElement.innerHTML.replace(/&/g, '&').replace(/</g, '<') + '</pre></html>'); win.document.close(); void 0;")
browser.quit()
开发者ID:ThePenguin1140,项目名称:jabbapylib,代码行数:16,代码来源:splinter_demo.py
示例14: test_adding_a_keypair
def test_adding_a_keypair(self):
self.browser = Browser()
self._logIn()
keypair = self.browser.find_link_by_text("Keypairs")
keypair.click()
self.lookForError()
keypair_btn = self.browser.find_by_id("keypairs_create_link")
keypair_btn.click()
self.browser.fill('name', "test_keypair_test")
# Create Keypair in d5
button = self.browser.find_by_value('Add Keypair')
button.click()
return_link = self.browser.find_link_by_partial_text("Return to keypairs")
return_link.click()
self.assertTrue(self.browser.is_text_present("test_keypair_test"),
"Created keypair not found")
delete_link = self.browser.find_by_id("delete_test_keypair_test")
delete_link.click()
# accept the js alert
alert = self.browser.get_alert()
alert.accept()
# verify delete message
self.assertTrue(self.browser.is_text_present(
"Successfully deleted keypair: test_keypair_test"),
"Keypair not successfully deleted")
self._logOut()
self.browser.quit()
开发者ID:rcbops,项目名称:kongui,代码行数:27,代码来源:test_admin_dashboard.py
示例15: test_instances_page
def test_instances_page(self):
self.browser = Browser()
self._logIn()
instances = self.browser.find_link_by_text("Instances")
instances.click()
self.lookForError()
self._logOut()
self.browser.quit()
开发者ID:rcbops,项目名称:kongui,代码行数:8,代码来源:test_admin_dashboard.py
示例16: __init__
def __init__(self, width = 500, height = 300):
"""
抖音App视频下载
"""
# 无头浏览器
chrome_options = Options()
chrome_options.add_argument('user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"')
self.driver = Browser(driver_name='chrome', executable_path='D:/chromedriver', options=chrome_options, headless=True)
开发者ID:Giten2004,项目名称:python-spider,代码行数:8,代码来源:douyin_pro.py
示例17: main
def main():
#browser = Browser('zope.testbrowser')
#browser = Browser('webdriver.chrome')
browser = Browser()
browser.visit(url)
#browser.execute_script("var win = window.open(); win.document.write('<html><head><title>Generated HTML of ' + location.href + '</title></head><pre>' + document.documentElement.innerHTML.replace(/&/g, '&').replace(/</g, '<') + '</pre></html>'); win.document.close(); void 0;")
while 'ORIGIN' not in browser.html:
sleep(5)
f = open("/tmp/source.html", "w")
print >>f, browser.html
f.close()
browser.quit()
print '__END__'
开发者ID:ThePenguin1140,项目名称:jabbapylib,代码行数:17,代码来源:splinter_2.py
示例18: setUp
def setUp(self, from_bdd=False):
if from_bdd:
if isinstance( self, BDDTestCase ):
browser_name = getattr(settings,'BDD_BROWSER','firefox')
self.browser = Browser(browser_name)
self.extra_setup()
else:
self.prepare_database()
开发者ID:danielfranca,项目名称:BDD4Django,代码行数:8,代码来源:helpers.py
示例19: test_forward_to_none_page
def test_forward_to_none_page(self):
"should not fail when trying to forward to none"
browser = Browser('zope.testbrowser')
browser.visit(EXAMPLE_APP)
browser.forward()
assert_equals(EXAMPLE_APP, browser.url)
browser.quit()
开发者ID:flaviamissi,项目名称:splinter,代码行数:7,代码来源:test_zopetestbrowser.py
示例20: downloadCSV
def downloadCSV( geneName ):
## import webdriver
from splinter.browser import Browser
## alternative driver api
## driver = webdriver.Chrome("C:/Users/Jeff/Downloads/chromedriver.exe")
## import the driver, and visit the exac.broadinstitute.org webpage
## b = driver.get("http://exac.broadinstitute.org/awesome?query=SAMD11")
## load chrome driver, visit targer url
b = Browser(driver_name="chrome")
url = "http://exac.broadinstitute.org/awesome?query=" + geneName
b.visit(url)
## find the LoF button, by web elementary inspect
button = b.find_by_id(u"consequence_lof_variant_button")
## trigger the button
button.click()
## find the Export to CSV button, also by web elementary inspect
button2 = b.find_by_id(u"export_to_csv")
## trigger the button, download the target CSV document
button2.click()
b.quit()
开发者ID:breezedu,项目名称:LossHomozygosity,代码行数:33,代码来源:D0627_pulldatafromweb.py
注:本文中的splinter.browser.Browser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论