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. UNIGUI与UNIURLFRAME的互动

    UniSession.JSCode('name_'+MainForm.UniURLFrame1.name+'_'+MainForm.UniURLFrame1.JSName+'.myinput4.inn ...

  2. 手写实现简单版IOC

    概述 IOC (Inversion of Control) 控制反转,大家应该都比较熟悉了.应该也都有用过,这里就不具体介绍了.自己平时也有用到过IOC,但是对它的具体实现原理只有一个模糊的概念,所以 ...

  3. 一个简单的将Markdown二级标题进行排序的脚本

    我在写博客<Linux的1000个命令>的时候,相对二级标题进行一下排序,方便阅读和查找,于是就有了这个小程序. #! /usr/bin/env python3 import os imp ...

  4. Data - 关于大数据

    历史与趋势 大数据的前世今生:诞生.发展.未来? 如何利用数据赚钱?大数据价值变现的10种商业模式及利弊分析 10大行业大数据应用痛点及解决策略 大数据凉了?不,流式计算浪潮才刚刚开始 概念与定义 关 ...

  5. 阅读Google Protocol Buffers 指南,整理pb语法

    官方网站: https://developers.google.com/protocol-buffers/docs/proto3 1.简单定义一个Message 类型 pb语法文件以"*.p ...

  6. springmvc的异步处理

         关于异步的好处我在这里就不多说了,自从servlet3.1规范发布以来,控制层的异步处理也越来越多的被人提及.而Spring5的webflux诞生也意味着Spring全方位对异步提供了支持. ...

  7. Spring Cloud Eureka 服务注册列表显示 IP 配置问题

    服务提供者向 Eureka 注册中心注册,默认以 hostname 的形式显示,Eureka 服务页面显示的服务是机器名:端口,并不是IP+端口的形式 ,可以通过修改服务提供者配置自己的 IP 地址, ...

  8. IdentityServer Token验证

    查看源码:https://github.com/IdentityServer/IdentityServer4/tree/release API使用Client Credentials的token验证是 ...

  9. textarea 带换行符保存数据与带换行符展示数据

    毕业设计进行ing~ 最近要想要实现一个站内邮箱,想要带换行地输出邮件主体内容. 这两天为了解决这个问题百度了好多东西,发现相关问题有很多记录,可能这确实是大多数初学者也碰到的问题.自己找了好多地方都 ...

  10. String 字符串中含有 Unicode 编码时,转为UTF-8

    1.单纯的Unicode 转码 String a = "\u53ef\u4ee5\u6ce8\u518c"; a = new String(a.getBytes("UTF ...