Python 3.4:Chromedrive,IEDriverServer,geckoDriver
import sys;
import time;
import os;
#from huoche import PythonTickt;
from splinter.browser import Browser;
#from splinter.driver.webdriver import BaseWebDriver, WebDriverElement;
#from splinter import Browser;
from selenium import webdriver;
from selenium.webdriver.common.keys import Keys;
import selenium.webdriver.chrome.service as service;
import traceback;
from selenium.webdriver import Chrome;
from selenium.webdriver.chrome.options import Options;
from pyvirtualdisplay import Display; '''
firepath="C:/Program Files/Mozilla Firefox/";
browser = webdriver.Firefox(firepath)
browser.get('http://www.yahoo.com')
assert 'Yahoo' in browser.title
elem = browser.find_element_by_name('p') # Find the search box
elem.send_keys('seleniumhq' + Keys.RETURN)
browser.quit()
''' # 浏览器的驱动 chrome http://chromedriver.storage.googleapis.com/index.html
# https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
#https://github.com/mozilla/geckodriver/releases #Firefox驱动 geckodriver
#http://selenium-release.storage.googleapis.com/index.html
# http://selenium-release.storage.googleapis.com/index.html?path=3.8/ #IE驱动 #https://sites.google.com/a/chromium.org/chromedriver/home
#https://sites.google.com/a/chromium.org/chromedriver/getting-started #https://github.com/SeleniumHQ/selenium/tree/master/py
#http://www.techbeamers.com/selenium-webdriver-python-tutorial/ #service = service.Service('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe')
#service.start()
#capabilities = {'chrome.binary': 'C:/Program Files (x86)/Google/Chrome/Application'}
#driver = webdriver.Remote(service.service_url, capabilities)
#driver.get('http://www.google.com/xhtml');
#time.sleep(5) # Let the user actually see something!
#driver.quit() executable_path = {'executable_path':'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'}; # **executable_path #打开了还是有异常# http://splinter.readthedocs.io/en/latest/api/driver-and-element-api.html
#splinter.browser.Browser(driver_name='firefox', *args, **kwargs)
path='C:/Program Files (x86)/Google/Chrome/Application/';
url = "https://kyfw.12306.cn/otn/leftTicket/init";
#huoche=huoche();chrome #driver = webdriver.Firefox();
#driver.get("http://www.google.com/"); # create a new Firefox session
'''
driver = webdriver.Firefox(firepath)
driver.implicitly_wait(30)
driver.maximize_window() # navigate to the application home page
driver.get("http://www.google.com") # get the search textbox
search_field = driver.find_element_by_id("lst-ib")
search_field.clear() # enter search keyword and submit
search_field.send_keys("Selenium WebDriver Interview questions")
search_field.submit() # get the list of elements which are displayed after the search
# currently on result page using find_elements_by_class_name method
lists= driver.find_elements_by_class_name("_Rm") # get the number of elements found
print ("Found" + str(len(lists)) + "searches:"); # iterate through each element and print the text that is
# name of the search i=0
for listitem in lists:
print (listitem)
i=i+1
if(i>10):
break # close the browser window
driver.quit() '''
# get the path of IEDriverServer
# https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
iepath="C:/Python34/IEDriverServer.exe"
dir = os.path.dirname(__file__)# 当前文件的地址
ie_driver_path =iepath;# dir + "\IEDriverServer.exe" # create a new Internet Explorer session
driver = webdriver.Ie(ie_driver_path)
driver.implicitly_wait(30)
driver.maximize_window() # navigate to the application home page
driver.get("http://www.google.com") # get the search textbox
search_field = driver.find_element_by_name("q") # enter search keyword and submit
search_field.send_keys("Selenium WebDriver Interview questions")
search_field.submit() # get the list of elements which are displayed after the search
# currently on result page using find_elements_by_class_name method
lists= driver.find_elements_by_class_name("r") # get the number of elements found
print ("Found" + str(len(lists)) + " searches:") # iterate through each element and print the text that is
# name of the search i=0
for listitem in lists:
print (listitem)
i=i+1
if(i>10):
break # close the browser window
driver.quit() '''
# get the path of ChromeDriverServer
dir = os.path.dirname(__file__)
chrome_driver_path = dir + "\chromedriver.exe" # create a new Chrome session
driver = webdriver.Chrome(chrome_driver_path)
driver.implicitly_wait(30)
driver.maximize_window() # navigate to the application home page
driver.get("http://www.google.com") # get the search textbox
search_field = driver.find_element_by_name("q") # enter search keyword and submit
search_field.send_keys("Selenium WebDriver Interview questions")
search_field.submit() # get the list of elements which are displayed after the search
# currently on result page using find_elements_by_class_name method
lists= driver.find_elements_by_class_name("r") # get the number of elements found
print ("Found" + str(len(lists)) + " searches:") # iterate through each element and print the text that is
# name of the search i=0
for listitem in lists:
print (listitem)
i=i+1
if(i>10):
break # close the browser window
driver.quit()
'''
browser=webdriver.Chrome() #first tab
browser.get('http:/reddit.com') #second tab
browser.execute_script("window.open('about:blank', 'tab2');")
browser.switch_to.window("tab2")
browser.get('http://bing.com') #Browser("chrome",**executable_path, fullscreen=True); #size=driver.manage().window().setSize(new Dimension(1024,768)); #options = Options();
#options.add_argument('--lang=en-us');
#global browser;
#browser = BaseWebDriver();
#browser.driver = Chrome(chrome_options=options); chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1366,768")
# https://sites.google.com/a/chromium.org/chromedriver/downloads
chrome_driver = 'C:/Program Files (x86)/Google/Chrome/Application/' driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=chrome_driver) driver.get("https://www.wikipedia.org/")
english_link = driver.find_element_by_css_selector("#js-link-box-en")
english_link.click() d = Display(visible=0, size=(800, 600));
d.start(); chrome_options = ChromeOptions()
chrome_options.add_argument('disable-setuid-sandbox'); b = Browser('chrome');
b.visit('http://www.google.com');
b.quit(); d.stop(); options = Options()
options.add_argument("window-size=1,1");
browser = BaseWebDriver()
browser.driver = Chrome(chrome_options=options)
browser.visit('https://www.google.com')
Python 3.4:Chromedrive,IEDriverServer,geckoDriver的更多相关文章
- 【python驱动】python进行selenium测试时GeckoDriver放在什么地方?
背景:用python进行selenium 关于b/s架构的测试,需要配置驱动否则程序无法执行 情况1:windows下放置GeckoDriver 步骤1:下载驱动 GeckoDriver下载地址fir ...
- python自动化测试学习目录
一.python学习目录 <1> ----python驱动 [python驱动]python进行selenium测试时GeckoDriver放在什么地方? python下浏览器静默运行驱动 ...
- 使用Python+selenium实现第一个自动化测试脚本
原blog 一,安装Python. python官方下载地址:https://www.python.org/downloads/ 安装后点击开始菜单,在菜单最上面能找到IDLE. IDLE是pytho ...
- python爬虫——selenium+firefox使用代理
本文中的知识点: python selenium库安装 firefox geckodriver的下载与安装 selenium+firefox使用代理 进阶学习 搭建开发环境: selenium库 fi ...
- python中使用selenium调用Firefox缺少geckodriver解决方法
from selenium import webdriver driver=webdriver.Firefox() 会报错 解决方法: 因为缺少geckodriver.exe,先到https://gi ...
- selenium chromedriver geckodriver iedriverserver下载
chromedriver与chrome的的对应版整理: chromedriver版本 chrome版本 v2.9 v31-v34 v2.10 v33-v36 v2.11 v36-v40 v2.12 v ...
- 关于 chromedriver、IEDriverServer、geckodriver 驱动器的几项注意点
1. 下载 chromedriver 和 IEDriverServer 时,都没有对应的 win64 版本,只能选择 win32,也一样可以: 2. 下载的 IEDriverServer 的版本号和S ...
- GeckoDriver+Selenium+Python的安装和使用
如果没有安装GeckoDriver会提示: selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executab ...
- 在Centos7上安装Python+Selenium+Firefox+Geckodriver
1.事先准备好Centos7的系统 Centos系统是CentOS Linux release 7.4.1708 (Core) 查看Centos内核版本命令cat /etc/centos-releas ...
随机推荐
- 【WPF】【UWP】借鉴 asp.net core 管道处理模型打造图片缓存控件 ImageEx
在 Web 开发中,img 标签用来呈现图片,而且一般来说,浏览器是会对这些图片进行缓存的. 比如访问百度,我们可以发现,图片.脚本这种都是从缓存(内存缓存/磁盘缓存)中加载的,而不是再去访问一次百度 ...
- 从零搭建java后台管理系统(一)框架初步搭建
框架搭建 一.初步设想,使用springboot,框架打算用到依赖 spring web,devTools,mysql,Aspect,Redis,Lombok,Freemark,Shiro,Rabbi ...
- 开源性能测试工具Locust使用篇(二)
那如何理解Locust和TaskSet这两个类呢? class HttpLocust(Locust) 在Locust类中,具有一个client属性,它对应着虚拟用户作为客户端所具备的请求能力,也就是我 ...
- Data - 关于大数据
历史与趋势 大数据的前世今生:诞生.发展.未来? 如何利用数据赚钱?大数据价值变现的10种商业模式及利弊分析 10大行业大数据应用痛点及解决策略 大数据凉了?不,流式计算浪潮才刚刚开始 概念与定义 关 ...
- Devops流程规范
芯盾时代_Devops_Docker操作说明及使用规范 北京芯盾时代科技有限公司 2019年1月 修订记录 版本号 修订人 修订日期 修订描述 v0.1 芯盾 2019/1/15 初次创建 v0.2 ...
- [EXP]Jenkins 2.150.2 - Remote Command Execution (Metasploit)
## # This module requires Metasploit: https://metasploit.com/download # Current source: https://gith ...
- shell中的算数
加法:let result=var1+var2result=$[$var1+var2]result=$(($var1+var2))result=`expr $var1 + $var2*` 加号前后有空 ...
- 模板引擎之-jade
##### 首先我们安装jade模板引擎并编译`npm install jade --global`在项目文件夹下创建一个`index.jade`文件,并且写入```doctypehtml head ...
- 边缘化搭建 DotNet Core 2.1 自动化构建和部署环境(上)
写在前面 写这篇文章的缘由是由于笔者的对新兴技术方向有所追求,但个人资产有限,只能容许购买一台阿里云低配1核2G服务器.服务器上搭建了 Centos7 & Docker & Jenki ...
- redis 五种数据类型
前言 前面学会了单机, 学会了集群, 但是redis咋用啊? 或者说, redis支持哪些数据类型呢? 常用的有五种: String , Hash, List, Set, zset(SortedSet ...