zoukankan      html  css  js  c++  java
  • selenium2-java 浏览器下进行登录

    完整代码实现如下:

    package linear;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;

    /*
     * 李盈辉
     *2016-12-2
     * */
    public class loginCase {
            // TODO Auto-generated constructor stub
        public static void main(String[] args) throws Exception{
                WebDriver driver;
                System.setProperty("webdriver.chrome.marionette","C:\Program Files (x86)\Google\Chrome\Application\geckodriver.exe");
                driver = new ChromeDriver();
                driver.manage().window().maximize();
                System.out.println("浏览器已经启动");
                //在网站注册账号,并替换成自己的账号和密码,即可实现登录
                driver.get("https://www.tangcredit.com/");
                driver.findElement(By.xpath("//div[@id='register518']/span[2]")).click();
                Thread.sleep(5000);
                driver.findElement(By.id("model_phone")).clear();
                driver.findElement(By.id("model_phone")).sendKeys("tell-phone");
                driver.findElement(By.id("model_password")).clear();
                driver.findElement(By.id("model_password")).sendKeys("password");
                driver.findElement(By.cssSelector("input.btn.btn-danger")).click();
                System.out.println("用户已经登录");
            }

    }

  • 相关阅读:
    Codeforces Round #744 (Div. 3) (CF1579) 题解
    Codeforces Round #748 (Div. 3) (CF1593)题解
    NOIP2018初赛游记
    模板:高精度
    博客园,初见安~~
    20200211学习
    nyoj 1103 区域赛系列一多边形划分
    南阳oj 845 无主之地1
    hdu 2080 夹角有多大II
    hdu 分拆素数和
  • 原文地址:https://www.cnblogs.com/qq738805997/p/6126627.html
Copyright © 2011-2022 走看看