码迷,mamicode.com
首页 > 编程语言 > 详细

selenium2-java 浏览器下进行登录

时间:2016-12-02 19:05:56      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:rom   ndk   generate   账号   register   manage   ati   com   files   

完整代码实现如下:

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("用户已经登录");
        }

}

selenium2-java 浏览器下进行登录

标签:rom   ndk   generate   账号   register   manage   ati   com   files   

原文地址:http://www.cnblogs.com/qq738805997/p/6126627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!