首页 技术 正文
技术 2022年11月21日
0 收藏 980 点赞 4,089 浏览 1717 个字

这篇可以不看,主要是为了以后的应用代码(传参)做铺垫。

import java.awt.Rectangle;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.imageio.ImageIO;

import org.openqa.selenium.By;
import org.openqa.selenium.Point;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

public class Login {
public static int t = 1;

static WebDriver driver = new ChromeDriver();

public void Loginindex(String url,String user,String pass) throws InterruptedException{

driver.get(url);

// 用下面代码也可以实现
// driver.navigate().to(“url”);
// 获取 网页的 title
// System.out.println(“1 Page title is: ” + driver.getTitle());
// 通过 id 找到 input 的 DOM
// try{
// WebElement element0 =driver.findElement(By.xpath(“//div[contains(@class,’user-info-mission-luckdraw-mask-body-close’)]”));
// element0.click();
// }catch(Exception e){
// System.out.println(“广告没有了”);
// //System.exit(0);
// }
WebElement element = driver.findElement(By.xpath(“//button[contains(@class,’Login’)]”));
// 输入关键字
element.click();
Thread.sleep(3000);
WebElement frame = driver.findElement(By.xpath(“//*[@id=’C_maijia-login’]/div/div/div/iframe”));
driver.switchTo().frame(frame);
WebElement element1 =driver.findElement(By.xpath(“//input[@name=’loginCode’]”));
element1.sendKeys(user);
WebElement element2 =driver.findElement(By.xpath(“//input[@name=’loginPassword’]”));
element2.sendKeys(pass);;
WebElement button =driver.findElement(By.xpath(“//button[contains(.,’登录’)]”));
button.click();
}

}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,023
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,360
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,143
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,774
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,852