Selenium codes

1)
//div[normalize-space(@class)='x-menu x-menu-floating x-layer']
equals
//div[@class='x-menu x-menu-floating x-layer' or @class='x-menu x-menu-floating x-layer ']

2)Double click

protected RemoteWebDriver webdriver ;
public void doubleClickElement(String xpath){
Actions actions = new Actions(webdriver); 
WebElement we = webdriver.findElement(By.xpath(xpath));
waitForElementPresent(By.xpath(xpath), 20);
Action action = actions.doubleClick(we).build();
    action.perform();
}

3) move to element

public void moveToElement(String xpath){
Actions actions = new Actions(webdriver); 
WebElement we = webdriver.findElement(By.xpath(xpath));
waitForElementPresent(By.xpath(xpath), 20);
Action action = actions.moveToElement(we).build();
    action.perform();
}

4) click element

public void clickElement(String xpath){
Actions actions = new Actions(webdriver); 
WebElement we = webdriver.findElement(By.xpath(xpath));
waitForElementPresent(By.xpath(xpath), 20);
Action action = actions.click(we).build();
    action.perform();
}

5) Wait for element

public void watiForElementDisabled(String Xpath) throws InterruptedException{
boolean ablibity = true;
while(ablibity){
try{
webdriver.findElement(By.xpath(Xpath));
Thread.sleep(10);
}catch(Exception e){
ablibity = false;
}

}
}

6)wait for element disabled

public void watiForElementDisabled(String Xpath) throws InterruptedException{
boolean ablibity = true;
while(ablibity){
try{
webdriver.findElement(By.xpath(Xpath));
Thread.sleep(10);
}catch(Exception e){
ablibity = false;
}

}
}

你可能感兴趣的:(selenium)