您的位置:首页 > 其它

SeleniuM的按键操作模拟键盘

2017-03-23 17:05 190 查看
package com.gloryroad.Demo;

import org.openqa.selenium.Keys;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.interactions.Action;

import org.openqa.selenium.interactions.Actions;

import org.testng.annotations.AfterMethod;

import org.testng.annotations.BeforeMethod;

import org.testng.annotations.Test;

public class clisckSene {
String url="http://www.sogou.com";
public WebDriver driver;
@BeforeMethod
public void setUp(){
driver=new FirefoxDriver();
driver.get(url);

}

@AfterMethod
public void tearDown(){
driver.close();
}
@Test
public void clickSend() throws InterruptedException{
Actions act=new Actions(driver);
act.sendKeys(Keys.CONTROL);
act.sendKeys(Keys.SHIFT);
act.sendKeys(Keys.ALT);
act.sendKeys(Keys.CONTROL);
act.sendKeys(Keys.SHIFT);
act.sendKeys(Keys.ALT);
act.keyDown(Keys.SHIFT).sendKeys("adfba").perform();
Thread.sleep(5000);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: