zoukankan      html  css  js  c++  java
  • selenium python 启动Firefox

    我的火狐浏览器版本是最新的:

    下载geckodrive:https://github.com/mozilla/geckodriver/releases/

    下载完后将exe文件放到这里“D:firefox”即firefox安装目录的快捷方式所在的文件夹,同时将这个路径放到path中:

    D:Python3Scripts;D:Python3;D:Python36-32Scripts;D:Python36-32;%JAVA_HOME%in;%JAVA_HOME%jrein;C:strawberrycin;C:strawberryperlin;C:Program FilesMySQLMySQL Utilities 1.6;C:Program FilesOpenVPNin;c:windowssystem32;E:Python;D:Python36-32;D:Python3;E:pythonpython3;C:UsersAdministratorAppDataLocalGoogleChromeApplication;D:firefox

    重启下PyCharm可以调用了:

     1 import time
     2 
     3 from selenium import webdriver
     4 import os
     5 
     6 username = "jiangpr_ok@163.com" # 请替换成你的用户名
     7 password = "d123456789d" # 请替换成你的密码
     8 
     9 # driver = webdriver.Chrome() # 选择Chrome浏览器
    10 driver = webdriver.Firefox()
    11 driver.get(url='http://vip.jd.com') # 打开京东会员网站
    12 time.sleep(1)
    13 
    14 
    15 driver.find_element_by_link_text('账户登录').click()
    16 driver.find_element_by_id('loginname').click()
    17 driver.find_element_by_id('loginname').send_keys(username)
    18 driver.find_element_by_id('nloginpwd').click()
    19 driver.find_element_by_id('nloginpwd').send_keys(password)
    20 
    21 driver.find_element_by_id('loginsubmit').click()
    22 time.sleep(1)
    23 driver.find_element_by_id('signIn').click()
  • 相关阅读:
    蘑菇街
    康拓展开
    CSS学习笔记
    专业名词
    专业名字
    01背包问题
    将bbr功能合入到centos7.3
    How to Identify User&Password of DataBase safely in SQL statement?
    tips for private constructor
    all Key Word of C#
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/9261820.html
Copyright © 2011-2022 走看看