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的更多相关文章

  1. 【python驱动】python进行selenium测试时GeckoDriver放在什么地方?

    背景:用python进行selenium 关于b/s架构的测试,需要配置驱动否则程序无法执行 情况1:windows下放置GeckoDriver 步骤1:下载驱动 GeckoDriver下载地址fir ...

  2. python自动化测试学习目录

    一.python学习目录 <1> ----python驱动 [python驱动]python进行selenium测试时GeckoDriver放在什么地方? python下浏览器静默运行驱动 ...

  3. 使用Python+selenium实现第一个自动化测试脚本

    原blog 一,安装Python. python官方下载地址:https://www.python.org/downloads/ 安装后点击开始菜单,在菜单最上面能找到IDLE. IDLE是pytho ...

  4. python爬虫——selenium+firefox使用代理

    本文中的知识点: python selenium库安装 firefox geckodriver的下载与安装 selenium+firefox使用代理 进阶学习 搭建开发环境: selenium库 fi ...

  5. python中使用selenium调用Firefox缺少geckodriver解决方法

    from selenium import webdriver driver=webdriver.Firefox() 会报错 解决方法: 因为缺少geckodriver.exe,先到https://gi ...

  6. selenium chromedriver geckodriver iedriverserver下载

    chromedriver与chrome的的对应版整理: chromedriver版本 chrome版本 v2.9 v31-v34 v2.10 v33-v36 v2.11 v36-v40 v2.12 v ...

  7. 关于 chromedriver、IEDriverServer、geckodriver 驱动器的几项注意点

    1. 下载 chromedriver 和 IEDriverServer 时,都没有对应的 win64 版本,只能选择 win32,也一样可以: 2. 下载的 IEDriverServer 的版本号和S ...

  8. GeckoDriver+Selenium+Python的安装和使用

    如果没有安装GeckoDriver会提示: selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executab ...

  9. 在Centos7上安装Python+Selenium+Firefox+Geckodriver

    1.事先准备好Centos7的系统 Centos系统是CentOS Linux release 7.4.1708 (Core) 查看Centos内核版本命令cat /etc/centos-releas ...

随机推荐

  1. 函数round和trunc

    1.round函数. round函数能够按照数学规则进行四舍五入的进位,以保留小数点后要求的位数. 使用方法为 round(<小数>,<保留的位数>) 下面是两个例子: ) f ...

  2. 利用ArcGIS-Server瓦片制作离线地图包(*.tpk)_详细流程

    1.写在前面 本人是综合了好几个资料才最终制作成功,在这个过程中发现网上好多博客写的步骤不是很详细,因此就把自己的详细制作步骤全部分享出来,可以供需要的小伙伴参考. (1)本文档不讨论tpk文件的详细 ...

  3. ng 的 ng-repeat(对象) 把对象的 key 和value 都拿出来 循环

    对象的repeat  是这种形式

  4. 腾讯大数据之TDW计算引擎解析——Shuffle

    转自 https://www.csdn.net/article/2014-05-19/2819831-TDW-Shuffle/1 摘要:腾讯分布式数据仓库基于开源软件Hadoop和Hive进行构建,T ...

  5. iOS开发笔记(Swift)-通用App安装引导页的实现

    之前一直做的项目都是基于OC开发的,最近开始尝试使用Swift语言来重写整个项目. 本篇文章主要是讲述如何使用Swift来实现常见的通用App安装引导界面. 效果预览: 实现思路: 主要是采用了UIS ...

  6. 内存管理buddy[原理]

    TODO------------------------------------------------------------------------------------------------ ...

  7. centos7使用lldb调试netcore应用转储dump文件

    centos7下安装lldb,dotnet netcore 进程生成转储文件,并使用lldb进行分析 随着netcore应用在linux上部署的应用越来越多,碰到cpu 100%,内存暴涨的情况也一直 ...

  8. laravel5实现第三方登录(微信)

    背景 最近手头一个项目需要实现用户在网站的第三方登录(微信和微博),后端框架laravel5.4. 实现过程以微信网页版第三方登录,其他于此类似,在此不做重复. 准备工作 网站应用微信登录是基于OAu ...

  9. 你(可能)不知道的web api

    你(可能)不知道的web api 简介 作为前端er,我们的工作与web是分不开的,随着HTML5的日益壮大,浏览器自带的webapi也随着增多.本篇文章主要选取了几个有趣且有用的webapi进行介绍 ...

  10. docker容器中Postgresql 数据库备份

    查看运行的容器: docker ps 进入目标容器: docker exec -u root -it 容器名 /bin/bash docker 中,以root用户,创建备份目录,直接执行如下命令, p ...