0
我有本地代码工作,但是当我用Sauce Labs帐户使用RemoteWebDriver时,该操作似乎被忽略。moveToElement不再适用于酱实验室
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端虚拟机的加载时间。有什么建议么?
非常感谢! –
如果您发现此(或任何)答案有帮助,请立即加入。如果这回答了您的问题,请将其标记为已接受的答案。谢谢! – JeffC