SeleniuM的按键操作模拟键盘

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);

}

}

你可能感兴趣的:(Java编程,测试经验总结)