随着公司业务的升级,现在的任务还需要向页面的输入框中输入登录名密码,输入用户名账户及金额,由于U盾安全程度太高最终向U盾输入支付密码时数不进去,但是对于安全程度不高的,以下方法完全能解决问题。
方法:
用selenium找到输入框标签然后进行输入,代码如下
public synchronized void send() throws InterruptedException {
System.out.println("代付发送中。。。");
Thread.sleep(2500);
driver.findElement(By.partialLinkText("首页")).click();
Thread.sleep(2500);
driver.findElement(By.partialLinkText("跨行转账")).click();
try {
Thread.sleep(3000);
WebElement inaccount = driver.findElement(By.id("Amount"));
inaccount.sendKeys("0.01");
Thread.sleep(2500);
WebElement name = driver.findElements(By.className("v-valid")).get(8);
name.sendKeys("朱哥");
Thread.sleep(2500);
WebElement account = driver.findElement(By.id("PayeeAcNo"));
account.sendKeys("6236683810004396543");
Thread.sleep(2500);
// WebElement bank=driver.findElement(By.id("IBPSPayeeBank"));
// bank.sendKeys("中国民生银行");
// Thread.sleep(1500);
WebElement Remark = driver.findElement(By.id("Remark"));
Remark.sendKeys("转账");
Thread.sleep(2500);
} catch (Exception e) {
log.info("信息错误,转款失败");
}
driver.findElement(By.name("Submit")).click();
Thread.sleep(2500);
// driver.findElements(By.className("anniucss")).get(1).click();
// Thread.sleep(2000);
try {
WebElement sub = driver.findElement(By.id("_ocx_passwordChar_pge"));
sub.sendKeys("123456");
Thread.sleep(2500);
driver.findElement(By.name("submit")).click();
} catch (Exception e) {
log.info("支付密码错误");
}
}
最后推荐大家向目标输入和点击等用录屏的方式,通过屏幕录制然后一步一步的做输入或点击等,链接:
https://blog.csdn.net/Z_Vivian/article/details/93848895