本文整理汇总了Python中selenium.webdriver.Firefox.get方法的典型用法代码示例。如果您正苦于以下问题:Python Firefox.get方法的具体用法?Python Firefox.get怎么用?Python Firefox.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.Firefox
的用法示例。
在下文中一共展示了Firefox.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_test2
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def test_test2(self):
"""
test_test2
"""
driver = Firefox()
driver.get('https://www.google.com/')
print('TestCaseCustomSearch test_test2')
示例2: CaptchaPage
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
class CaptchaPage():
def __init__(self):
print "Captcha Page Initializing"
parser = ConfigParser.ConfigParser()
base_path = os.path.join(os.environ['HOME'], '.mozilla/firefox/')
parser.read(os.path.join(base_path, "profiles.ini"))
profile_path = os.path.join(base_path, filter(lambda x: x[0].lower() == 'path', parser.items('Profile0'))[0][1])
try:
profile = FirefoxProfile(profile_path)
except OSError:
raise Exception("You must execute the following command:\nsudo chmod +r -R %s" % profile_path)
self.driver = Firefox(profile)
self.driver.get("file://%s/index.html" % os.getcwdu())
def get_url_sound(self):
self.driver.find_element_by_xpath('//*[@id="recaptcha_switch_audio"]').click()
return self.driver.find_element_by_xpath('//*[@id="recaptcha_audio_download"]').get_attribute('href')
def get_recaptcha_challenge_field(self):
return self.driver.find_element_by_xpath('//*[@id="recaptcha_challenge_field"]').get_attribute('value')
def get_captcha_textbox(self):
print "Getting Captcha Textbox"
return Textbox(self.driver.find_element_by_xpath('//*[@id="recaptcha_response_field"]'))
def get_submit_button(self):
print "Getting Submit Form Button"
return Button(self.driver.find_element_by_xpath("/html/body/form/input"))
def close(self):
print "Closing Captcha Page"
self.driver.close()
示例3: add_advert
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def add_advert():
print("Add new advertisement.")
g = Grab(log_file="2.html")
g.load_cookies('cookies.txt')
g.go("http://m.avito.ru/add")
#login_test()
from selenium.webdriver import Firefox
from selenium.webdriver.common.keys import Keys
import selenium
from PIL import Image
browser = Firefox()
driver = selenium.webdriver.Firefox()
browser.get('http://m.avito.ru/profile/login')
driver.implicitly_wait(10)
elem = driver.find_element_by_css_selector(".control-self.control-self-email")
elem.send_keys("[email protected]")
"""
driver.find_element_by_name("password")
element.send_keys("ivveqaem")
driver.find_element_by_class_name("control-self control-self-submit button button-solid button-blue button-large")
driver.find_element_by_partial_link_text("Войти")
element.send_keys(Keys.ENTER)
"""
#browser.get('http://m.avito.ru/add')
browser.save_screenshot('current_page')
current_page_img = Image.open('current_page')
w, h = current_page_img.size
captcha_img = current_page_img#.crop((575, 505, w-155, h-1820))
captcha_img.save('captcha.jpg', 'jpeg')
示例4: Scraper
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
class Scraper(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.url = 'http://www.jerryvarghese.com/Job-Search/ReqSearch.aspx?p=0&locID=121&loc=Saudi%20Arabia'
#self.base_job_url = 'https://sjobs.brassring.com/TGWebHost/jobdetails.aspx?'
self.browser = Firefox()
self.first_page_search_opening_id = 'srchOpenLink'
self.second_page_search_btn_id = 'ctl00_MainContent_submit2'
self.next_link_id = 'yui-pg0-0-next-link'
def page_links(self):
job_link_id = 'Openings1_Rptr_FieldName_ct{}_lknReqTitle'
for i in range(100, 115):
link_id = job_link_id.format(str(i))
link = self.browser.find_element_by_id(link_id)
link.click()
def main(self):
try:
self.browser.get(self.url)
self.page_links()
counter = 1
except Exception as e:
print 'exception= ', str(e)
#print 'stacktrace= ', traceback.print_exc()
print 'Line Number= ' + str(sys.exc_traceback.tb_lineno)
示例5: ff
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def ff():
browser = Firefox()
browser.get('https://www.charter.com/browse/content/new-channel-lineup')
wait = WebDriverWait('browser', 20)
button = browser.find_element_by_xpath('//*[@id="select-state"]/div[2]') # find and click Choose State button
button.click()
示例6: __init__
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
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 "---------------"
示例7: control
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def control(request):
driver = Firefox()
site = os.path.abspath(os.path.dirname(__file__))
site = os.path.join(site, 'test.html')
driver.get(site)
request.instance.page = MainPage(driver)
def fin():
driver.quit()
request.addfinalizer(fin)
示例8: __init__
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def __init__(self):
CrawlSpider.__init__(self)
log.start(logfile="./log/szlib-%s.log" % strftime("%m%d-%H-%M",localtime(time())), loglevel=log.INFO,logstdout=False)
log.msg("szlibspider start")
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("//div[@class='boxtext']/div[@class='filterbox_1']/div[@class='text tab_4_tit district_list']/a")
num = "wijefowaeofjwejf SSL0011"
selflibs_num = []
for district in elements[1:]:
log.msg("%s selflibs:" % district.text)
log.msg("==================")
district.click()
WebDriverWait(ffdriver,30).until(ajax_complete, "Timeout waiting to load selflibs")
selflibs_elements = ffdriver.find_elements_by_xpath("//ul[@class='servicepointlist']/li[@class='item']")
for selflib_ele in selflibs_elements:
# num = selflib_ele.find_element_by_class_name("num").text
num = selflib_ele.find_element_by_class_name("num").get_attribute("textContent")
log.msg("num %s" % num)
selflibs_num.append(num[-7:])
log.msg("numid %s" % num[-7:] )
log.msg("%s" % selflib_ele.find_element_by_class_name("title").get_attribute("textContent"))
log.msg("%s" % selflib_ele.find_element_by_class_name("text").get_attribute("textContent"))
log.msg("---------------")
log.msg("------1---------")
# ffdriver.quit()
# numstr = unicode("编号","utf-8")
# numstr = unicode(num,"utf-8")
# log.msg("numstr is in num? %s" % (numstr in num))
# log.msg("%s,%s, %s" % (num,num[1], num[-7:]))
for selflibnum in selflibs_num:
selflib_url ="http://www.szlib.gov.cn/libraryNetwork/dispSelfLibBook/id-5/%s.html" % selflibnum
log.msg("selflib url %s" % selflib_url)
ffdriver.get(selflib_url)
WebDriverWait(ffdriver,30).until(ajax_complete, "Timeout waiting to load booklist")
categorys_elements = ffdriver.find_elements_by_xpath("//div[@class='boxtext']/div[@class='filterbox_1']/div[@class='text tab_4_tit category']/a")
for category_ele in categorys_elements[1:]:
log.msg("%s" % category_ele.text)
示例9: test_rendering_utf8_iframe
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def test_rendering_utf8_iframe():
iframe = elem.IFrame(html=u'<p>Cerrahpaşa Tıp Fakültesi</p>')
options = Options()
options.add_argument('-headless')
driver = Firefox(options=options)
driver.get('data:text/html,' + iframe.render())
driver.switch_to.frame(0)
assert u'Cerrahpaşa Tıp Fakültesi' in driver.page_source
示例10: print_prices
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def print_prices():
driver = Firefox()
driver.get("https://cars.mail.ru/sale/msk/all/?order=price&dir=asc")
elements = [None] * 20
for i in range(0, 20):
print 'finding by xpath', i
elements[i] = WebDriverWait(driver, 10).until(
lambda d: d.find_element_by_xpath('(//span[@class="offer-card__price__value"])[%d]' % (i + 1,)))
for i in range(0, 20):
print 'text', elements[i].text
driver.quit()
示例11: main
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser()
parser.add_argument('--url', default='http://127.0.0.1:8000/static/index.html')
args = parser.parse_args(argv)
url = args.url
browser = WebDriver()
browser.get(url)
tags = browser.find_elements_by_css_selector('li')
for tag in tags:
print(tag.text)
browser.close()
示例12: DIMA_WIN
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
class DIMA_WIN():
ROOT_URL = "http://detki.co.il/photo/photokonkurs1.html/"
VOIT_URL = "http://detki.co.il/photo/photokonkurs1.html?vote=5&star_id=30"
CSS = "/html/body"
def __init__(self):
try:
self.driver = Firefox(timeout=10)
# self.driver.get(self.ROOT_URL)
# alert = self.driver.switch_to_alert()
# WebDriverWait(self.driver, 15)
except (Exception, ) as e:
print e
self.driver.quit()
def wait(self, issue, search_type='css'):
try:
if search_type == 'css':
WebDriverWait(self.driver, timeout=60).until(
lambda x: x.find_element(By.XPATH, issue))
elif search_type == 'id':
WebDriverWait(self.driver, timeout=60).until(
lambda x: x.find_element(By.ID, issue))
except (TimeoutException, Exception) as e:
print e
self.driver.quit()
def start(self):
try:
with timeout(10): # AVOID AUTH WINDOW
self.driver.get(self.ROOT_URL)
except (Exception,) as e:
print e
self.driver.quit()
def voit(self):
try:
with timeout(120): # AVOID AUTH WINDOW
self.driver.get(self.ROOT_URL)
WebDriverWait(self.driver, 20)
actions = ActionChains(self.driver)
# li = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div[1]/div[1]/ul/li[38]/div/div[1]/ul/li[6]/a')
lli = self.driver.find_element_by_css_selector('#content > div > div.large-12.columns > div:nth-child(2) > div.large-8.columns > ul > li:nth-child(38) > div > div.large-7.columns > ul > li:nth-child(6) > a')
actions.click(lli)
print "clicked"
except (Exception,) as e:
print e
finally:
self.driver.quit()
示例13: get_air_data
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def get_air_data(positionsets):
# Dictionary hourdata is for holding data, DataStructure like:
# {'baiyunshan': [44, 5], 'haizhubaogang': [55, 6]}
hourdata = {}
# Calling selenium, need linux X
browser = Firefox()
browser.get(URL)
# Added 10 seconds for waiting page for loading.
time.sleep(10)
# Click button one-by-one
for position in positionsets:
# After clicking, should re-get the page_source.
browser.find_element_by_id(position).click()
page_source = browser.page_source
# Cooking Soup
soup = BeautifulSoup(page_source, 'html.parser')
# pm2.5 value would be something like xx 微克/立方米, so we need an regex for
# matching, example: print int(pattern.match(input).group())
try:
PM25 = int(pattern.match(soup.find('td',{'id': 'pmtow'}).contents[0]).group())
PM25_iaqi = int(pattern.match(soup.find('td',{'id': 'pmtow_iaqi'}).contents[0]).group())
PM10 = int(pattern.match(soup.find('td',{'id': 'pmten'}).contents[0]).group())
PM10_iaqi = int(pattern.match(soup.find('td',{'id': 'pmten_iaqi'}).contents[0]).group())
SO2 = int(pattern.match(soup.find('td',{'id': 'sotwo'}).contents[0]).group())
SO2_iaqi = int(pattern.match(soup.find('td',{'id': 'sotwo_iaqi'}).contents[0]).group())
NO2 = int(pattern.match(soup.find('td',{'id': 'notwo'}).contents[0]).group())
NO2_iaqi = int(pattern.match(soup.find('td',{'id': 'notwo_iaqi'}).contents[0]).group())
# Special notice the CO would be float value
CO = float(floatpattern.match(soup.find('td',{'id': 'co'}).contents[0]).group())
CO_iaqi = int(pattern.match(soup.find('td',{'id': 'co_iaqi'}).contents[0]).group())
O3 = int(pattern.match(soup.find('td',{'id': 'othree'}).contents[0]).group())
O3_iaqi = int(pattern.match(soup.find('td',{'id': 'othree_iaqi'}).contents[0]).group())
hourdata_key = pinyin.get(position)
hourdata[hourdata_key] = []
hourdata[hourdata_key].append(PM25)
hourdata[hourdata_key].append(PM25_iaqi)
hourdata[hourdata_key].append(PM10)
hourdata[hourdata_key].append(PM10_iaqi)
hourdata[hourdata_key].append(SO2)
hourdata[hourdata_key].append(SO2_iaqi)
hourdata[hourdata_key].append(NO2)
hourdata[hourdata_key].append(NO2_iaqi)
hourdata[hourdata_key].append(CO)
hourdata[hourdata_key].append(CO_iaqi)
hourdata[hourdata_key].append(O3)
hourdata[hourdata_key].append(O3_iaqi)
except ValueError, Argument:
# won't add the data, simply ignore this position
print "The argument does not contain numbers\n", Argument
示例14: __init__
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
class ContentRetrieverUsingSelenium:
def __init__(self, timeout):
self.browser = Firefox()
self.timeout = timeout
def getContentOfPage(self, url):
self.browser.get(url)
time.sleep(self.timeout)
page_source = self.browser.page_source
page_source = page_source.encode('gbk', 'ignore')
return (self.browser.current_url, BeautifulSoup(page_source))
def close(self):
self.browser.close()
示例15: test_add_extension_web_extension_with_id
# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import get [as 别名]
def test_add_extension_web_extension_with_id(capabilities, webserver):
current_directory = os.path.dirname(os.path.realpath(__file__))
root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
# TODO: This file should probably live in a common directory.
extension_path = os.path.join(root_directory, 'javascript', 'node', 'selenium-webdriver',
'lib', 'test', 'data', 'firefox', 'webextension.xpi')
profile = FirefoxProfile()
profile.add_extension(extension_path)
driver = Firefox(capabilities=capabilities, firefox_profile=profile)
profile_path = driver.firefox_profile.path
extension_path_in_profile = os.path.join(profile_path, 'extensions', '[email protected]')
assert os.path.exists(extension_path_in_profile)
driver.get(webserver.where_is('simpleTest.html'))
driver.find_element_by_id('webextensions-selenium-example')
driver.quit()