2017-12-26 10 views
0
Actions actions = new Actions(getDriver()); 
Robot robot = null; 

try { 
    robot = new Robot(); 
} catch (AWTException e) { 
    e.printStackTrace(); 
} 

robot.mouseMove(700,700); 
actions.click().build().perform(); 

위 코드를 시도했지만 작동하지 않습니다. 마우스가 원하는대로 움직이지만 클릭하지는 않습니다. "actions.click().build().perform()" 아무 것도하지 않았습니다.웹 페이지의 아무 곳이나 클릭하는 방법

다른 생각이 있으십니까?

답변

0

코드에 Robot 클래스와 Action 클래스를 함께 사용하고 있습니다. 당신의 목표는 페이지를 클릭 할 경우, 다음 코드는 트릭을 할해야 -

WebElement body = driver.findElement(By.tagName("body")); 
Actions actions= new Actions(driver).click(body); 
actions.build().perform(); 

당신이 특정 위치를 클릭 할 경우, 당신이 도움이 moveByOffset 방법 -

Actions actions = new Actions(driver); 
actions.moveByOffset(700,700); 
actions.build().perform(); 

희망을 사용할 수 있습니다.

+0

actions.click(). build(). perform(); 두 번째 예에서 – Anoretu