selenium frame/window/cookies/Action

Cookie manage:

1.       把user data add进去chromeoptions里面

ChromeOptions options = new ChromeOptions();    options.addArguments("user-data-dir=C:\\Users\\zhaotang\\AppData\\Local\\Google\\Chrome\\User Data");

2.       先登录,然后 driver.manage().getCookies(); 

GetName,getvalue,getDomain,getPath,getExpiry,getSecure

然后再 Cookie ck = new Cookie(name,value,domain,path,expiry,secure)

直接访问登陆后的url就可以免登陆

 

Switchtowindow:

1.  拿到当前所有window  driver.getWindowHandles();

2.  For() 一个个window的切换过去,当window.gettitle=你需要的,break

 

操作键盘:

1.       ((RemoteWebDriver) driver).getKeyboard().sendKeys(Keys.ENTER);

2.       Actions action = new Actions(driver);

action.keyDown(Keys.CONTROL).sendKeys("p").perform();// 点击键盘 “p”

action.sendKeys(Keys.ENTER).perform();

3.       Java的Robot

Robot robot = new Robot();

robot.keyRelease(KeyEvent.VK_DOWN);

robot.keyPress(KeyEvent.VK_ENTER);

 

posted @ 2016-03-28 22:05  q55091  阅读(168)  评论(0编辑  收藏  举报