selenium怎么模拟键盘给div赋值,求解????
1个回答
展开全部
1.模拟键盘事件
Actions action = new Actions(driver); action.keyDown(Keys.CONTROL); action.keyDown(Keys.SHIFT); action.keyDown(Keys.ALT); action.keyUp(Keys.CONTROL); action.keyUp(Keys.SHIFT); action.keyUp(Keys.ALT); action.keyDown(Keys.SHIFT).sendKeys("adc").perform();
2.模拟右键点击事件
Actions action = new Actions(driver); action.contextClick(driver.findElement(By.id("query"))).perform();
3.指定元素上方进行鼠标悬浮
<html> <head> <meta http-equiv="Content-type" content="text/html;charset=gb2312"/> <script language="javascript"> function shownone() { document.getElementById('div1').style.display="none"; } function showBlock() { document.getElementById('div1').style.display="block"; }
Actions action = new Actions(driver); action.keyDown(Keys.CONTROL); action.keyDown(Keys.SHIFT); action.keyDown(Keys.ALT); action.keyUp(Keys.CONTROL); action.keyUp(Keys.SHIFT); action.keyUp(Keys.ALT); action.keyDown(Keys.SHIFT).sendKeys("adc").perform();
2.模拟右键点击事件
Actions action = new Actions(driver); action.contextClick(driver.findElement(By.id("query"))).perform();
3.指定元素上方进行鼠标悬浮
<html> <head> <meta http-equiv="Content-type" content="text/html;charset=gb2312"/> <script language="javascript"> function shownone() { document.getElementById('div1').style.display="none"; } function showBlock() { document.getElementById('div1').style.display="block"; }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询