use of org.openqa.selenium.UnsupportedCommandException in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method createWebDriver.
/**
* Creates a {@link WebDriver} for each test, then make sure to clean it up at the end.
*/
@Provides
@TestScope
public WebDriver createWebDriver(TestCleaner cleaner, TestName testName, ElasticTime time) throws IOException {
WebDriver base = createWebDriver(cleaner, testName);
// Make sure the window has minimal resolution set, even when out of the visible screen.
// Note - not maximizing here any more because that doesn't do anything.
Dimension oldSize = base.manage().window().getSize();
if (oldSize.height < 1050 || oldSize.width < 1680) {
base.manage().window().setSize(new Dimension(1680, 1050));
}
final EventFiringWebDriver d = new EventFiringWebDriver(base);
d.register(new Scroller());
try {
d.manage().timeouts().pageLoadTimeout(time.seconds(PAGE_LOAD_TIMEOUT), TimeUnit.MILLISECONDS);
d.manage().timeouts().implicitlyWait(time.seconds(IMPLICIT_WAIT_TIMEOUT), TimeUnit.MILLISECONDS);
} catch (UnsupportedCommandException e) {
// sauce labs RemoteWebDriver doesn't support this
LOGGER.info(base + " doesn't support page load timeout");
}
cleaner.addTask(new Statement() {
@Override
public void evaluate() {
switch(getBrowser()) {
case "firefox":
case "saucelabs-firefox":
case "remote-webdriver-firefox":
// https://github.com/mozilla/geckodriver/issues/1151
// https://bugzilla.mozilla.org/show_bug.cgi?id=1264259
// https://bugzilla.mozilla.org/show_bug.cgi?id=1434872
d.navigate().to("about:mozilla");
Alert alert = ExpectedConditions.alertIsPresent().apply(d);
if (alert != null) {
alert.accept();
d.navigate().refresh();
}
}
d.quit();
}
@Override
public String toString() {
return "Close WebDriver after test";
}
});
return d;
}
use of org.openqa.selenium.UnsupportedCommandException in project selenium_java by sergueik.
the class BaseTest method createWindow.
// based on
// http://automated-testing.info/t/kak-ya-mogu-otkrit-v-firefox-dve-vkladki-i-perehodit-s-odnoj-na-vtoruyu-pri-neobhodimosti/1741/4
// Creates a new window / browser tab using script injection
// Loads a specified url there
protected String createWindow(String url) {
Set<String> oldHandles = driver.getWindowHandles();
parentHandle = driver.getWindowHandle();
// Inject an anchor element
String name = "Window_" + instanceCount++;
executeScript("var anchorTag = document.createElement('a'); " + "anchorTag.appendChild(document.createTextNode('nwh'));" + "anchorTag.setAttribute('id', arguments[0]);" + "anchorTag.setAttribute('href', arguments[1]);" + "anchorTag.setAttribute('target', '_blank');" + "anchorTag.setAttribute('style', 'display:block;');" + "var firstElement = document.getElementsByTagName('body')[0].getElementsByTagName('*')[0];" + "firstElement.parentElement.appendChild(anchorTag);", name, url);
// common error with this approach: Element is not clickable at point
// HTML, HEAD, BODY, some element
WebElement element = driver.findElement(By.id(name));
sleep(1000);
try {
// element.getLocation()
System.err.println("Scrolling to " + element.getLocation().y);
scroll(element.getLocation().x, element.getLocation().y);
} catch (UnsupportedCommandException e) {
}
scrolltoElement(element);
// Click on the anchor element
element.click();
Set<String> newHandles = driver.getWindowHandles();
newHandles.removeAll(oldHandles);
// the remaining item is the new window handle
for (String handle : newHandles) {
return handle;
}
return null;
}
use of org.openqa.selenium.UnsupportedCommandException in project mycore by MyCoRe-Org.
the class SideBarIT method testSideBarResize.
@Test
public /**
* Ignored because https://github.com/mozilla/geckodriver/issues/233
*/
void testSideBarResize() throws Exception {
this.setTestName(getClassname() + "-testSideBarResize");
this.getDriver();
this.getAppController().openViewer(this.getDriver(), getTestDerivate());
ImageViewerController controller = this.getViewerController();
ToolBarController tbController = controller.getToolBarController();
SideBarController sbController = controller.getSideBarController();
tbController.pressButton(ToolBarController.BUTTON_ID_SIDEBAR_CONTROLL);
tbController.clickElementById(ImageOverviewController.IMAGE_OVERVIEW_SELECTOR);
int sbWidthStart = sbController.getSideBarWidth();
try {
// Firefox does not support actions so we just let the test pass.
sbController.dragAndDropByXpath("//div[contains(@class,\"sidebar\")]/span[@class=\"resizer\"]", 50, 0);
} catch (UnsupportedCommandException e) {
LOGGER.warn("Driver does not support Actions", e);
return;
}
int sbWidthEnd = sbController.getSideBarWidth();
assertLess(sbWidthEnd, sbWidthStart, "Sidebar width schould be increased!");
}
use of org.openqa.selenium.UnsupportedCommandException in project mycore by MyCoRe-Org.
the class SideBarIT method testOverviewLayout.
@Test
public void testOverviewLayout() throws InterruptedException {
this.setTestName(getClassname() + "-testOvervieLayout");
this.getDriver();
this.getAppController().openViewer(this.getDriver(), getTestDerivate());
ImageViewerController controller = this.getViewerController();
ToolBarController tbController = controller.getToolBarController();
SideBarController sbController = controller.getSideBarController();
tbController.pressButton(ToolBarController.BUTTON_ID_SIDEBAR_CONTROLL);
tbController.clickElementById(ImageOverviewController.IMAGE_OVERVIEW_SELECTOR);
int before = sbController.countThumbnails();
try {
sbController.dragAndDropByXpath("//div[contains(@class,'sidebar')]/span[@class='resizer']", 300, 0);
} catch (UnsupportedCommandException e) {
LOGGER.warn("Driver does not support Actions", e);
return;
}
Thread.sleep(1000);
int after = sbController.countThumbnails();
Assert.assertEquals(2 * before, after);
}
Aggregations