2017-03-17 8 views
0

코드가 로컬로 작동하지만 RemoteWebDriver를 Sauce Labs 계정과 함께 사용할 경우 작업이 무시되는 것 같습니다.moveToElement가 Sauce Labs와 더 이상 작동하지 않습니다.

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.interactions.Actions; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.remote.RemoteWebDriver; 
import java.net.URL; 

public class NavToURL { 
    public static final String USERNAME = "uname"; 
    public static final String ACCESS_KEY = "uuid"; 
    public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub"; 

    public static void main(String[] args) throws Exception { 
     DesiredCapabilities caps = DesiredCapabilities.chrome(); 
     caps.setCapability("platform", "Windows 7"); 
     caps.setCapability("version", "51.0"); 
     caps.setCapability("screenResolution", "1280x768"); 

     WebDriver driver = new RemoteWebDriver(new URL(URL), caps); 

     driver.get("http://www.webpage.com"); 
     try { 
      Thread.sleep(5000); 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
     } 
     driver.findElement(By.id("menu-item-177")).click(); 
     Thread.sleep(10000); 
     WebElement emailBox = driver.findElement(By.id("email")); 
     Actions actions = new Actions(driver); 
     actions.moveToElement(emailBox); 
     emailBox.sendKeys("[email protected]"); 
     driver.findElement(By.className("submit-button")).click(); 
     driver.quit(); 
    } 
} 

SauceLabs 쪽 VM의로드 시간을 줄이기 위해 절전 타이머를 추가하기까지했습니다. 어떤 제안?

답변

1

.build().perform();을 추가하는 것을 잊었습니다. . 나는 Sauce Labs에서 Actions을 사용하며 Chrome에서는 잘 작동하지만 FF 용의 마리오 네트 드라이버에서는 구현되지 않았기 때문에 IE가 적합합니다.

+0

완벽하게 감사했습니다. –

+0

도움이되는 (또는 어떤) 대답을 찾으면 그것을 upvote하십시오. 이 질문에 대한 답변이 있으면 대답으로 표시하십시오. 감사! – JeffC