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 ...
随机推荐
- [转]语音识别中区分性训练(Discriminative Training)和最大似然估计(ML)的区别
转:http://blog.sina.com.cn/s/blog_66f725ba0101bw8i.html 关于语音识别的声学模型训练方法已经是比较成熟的方法,一般企业或者研究机构会采用HTK工具包 ...
- WebRTC 学习之 Conference 实现混音混屏
混音 混音的意义就是将多个音频流混成一路音频,在Conference 的实现中有分为终端实现和服务器实现. 1. 终端混音实现: 终端接受到多路(一般是多个用户)的音频流之后,在终端本地将多路音频流混 ...
- 在notepad++中使用正则匹配功能(一-龥!-~) 中文[利刃篇]
用正则时间越久,人就越懒,就越知道正则的强大.正则,不只是在代码里用到,在字符查找是也会用到,学会适当使用正则,将会使你的工作事办功倍!但是,中文却是一个砍,不容易过. 于是在用notepad++,也 ...
- 一站式SpringBoot for NoSQL Study Tutorial 开发教程学习手册
SpringBoot2.0 + NoSQL使用教程,项目名称:“SpringBoot2NoSQL” 项目地址: https://gitee.com/475660/SpringBoot2NoSQL 项目 ...
- 转载 用Python实现设计模式——工厂模式
转载自 SegmentFault作者 夏秋, https://segmentfault.com/a/1190000013053013 非常感谢这位作者的深入浅出的讲解. 前言 工厂模式,顾名思义就是我 ...
- web自动化测试(java)---元素定位
和python类似,java-selenium也提供了很多种元素定位的方法,具体如下: findElement(By.id()) findElement(By.name()) findElement( ...
- shell之实战应用一(查找xml文档中的关键字段)
前几天同事问我一个问题,说如下的文档中,如何把name后面的字段(红色框中的字段)单独打印出来?
- C# datagridview分页功能
winform开发是或多或少都会接触datagridview控件,如果数据量大,那么必须使用分页功能,但是datagridview自身并没有分页,所以我们要自己实现.在网上搜了一些发现没有太适合自己的 ...
- Android_注解+反射代替findViewById()
最近没啥事,前段时间看到一个框架是使用的注解来代替findViewById()的然后就研究了,发现还是蛮容易的,下面就是注解的代码: import java.lang.annotation.Docum ...
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(二十三):配置中心(Config、Bus)
在线演示 演示地址:http://139.196.87.48:9002/kitty 用户名:admin 密码:admin 技术背景 如今微服务架构盛行,在分布式系统中,项目日益庞大,子项目日益增多,每 ...