com.github.siwenyan.si.SiCommandExecutorSetWindowSize Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of side Show documentation
Show all versions of side Show documentation
Java runner of Selenium IDE project
package com.github.siwenyan.si;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriverException;
class SiCommandExecutorSetWindowSize extends SiCommandExecutor implements ISiCommandExecutorFlagUi {
@Override
public void execute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
String sSize = command.getSiModelCommand().getTarget();
String[] p = sSize.split("x", 2);
int width = Integer.parseInt(p[0]);
int height = Integer.parseInt(p[1]);
try {
siContext.asWebDriver().manage().window().setSize(new Dimension(width, height));
} catch (WebDriverException e) {
String message = e.getMessage();
if (message.startsWith("setWindowRect")) {
siContext.getReporter().reportMessage("Using javascript...");
siContext.asJavascriptExecutor().executeScript("window.resizeTo(" + width + ", " + height + ")");
} else {
throw e;
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy