List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.wkrdp.WebKitNotificationListener.java
License:Apache License
@Override public void onMessage(IOSMessage message) { if (message instanceof ReportSetupMessage) { ReportSetupMessage m = (ReportSetupMessage) message; driver.setDevice(m.getDevice()); sync.signalSimRegistered();/*from www .jav a 2s . c o m*/ } if (message instanceof ReportConnectedApplicationsMessage) { ReportConnectedApplicationsMessage m = (ReportConnectedApplicationsMessage) message; if (m.getApplications().size() == 0) { log.warning("ReportConnectedApplicationsMessage reported 0 app."); } else { driver.setApplications(m.getApplications()); sync.signalSimSentApps(); } } if (message instanceof ApplicationSentListingMessage) { ApplicationSentListingMessage m = (ApplicationSentListingMessage) message; List<WebkitPage> messagePages = m.getPages(); List<WebkitPage> driverPages = driver.getPages(); boolean equals = WebkitPage.equals(messagePages, driverPages); log.fine("pages " + (equals ? "equals" : "CHANGED") + ": " + driverPages + " -> " + messagePages + ": " + m); if (equals) { return; } if (session.getApplication().isSafari()) { int change = m.getPages().size() - driver.getPages().size(); log.fine("ApplicationSentListingMessage: message pages: " + m.getPages().size() + ", change: " + change); // a new page appeared. The driver needs to know. if (change > 0) { List<WebkitPage> pages = new ArrayList<WebkitPage>(); // keep all the pages currently known to the driver pages.addAll(driver.getPages()); // remove all the pages we already know of from the message for (WebkitPage p : driver.getPages()) { m.getPages().remove(p); } if (m.getPages().size() == 0) { throw new WebDriverException(m.getPages().size() + " new pages."); } // TODO there can be more than one 'new' UIWebView, picking the first one for now. WebkitPage newOne = m.getPages().get(0); int index = driver.getPages().size() == 0 ? 0 : session.getRemoteWebDriver().getWindowHandleIndex() + 1; pages.add(index, newOne); driver.setPages(pages); if (driver.getPages().size() == 0) { //log.fine("first page. Nothing to do."); } else if (newOne.isITunesAd()) { //log.fine("itunes ad - ignoring it."); } else { WebkitPage focus = newOne; if (session != null) { waitForWindowSwitchingAnimation(); driver.switchTo(focus); } else { driver.switchTo(focus); } } // a page disappeared, the driver needs to know. } else if (change < 0) { List<WebkitPage> old = new ArrayList<WebkitPage>(); old.addAll(driver.getPages()); for (WebkitPage p : m.getPages()) { old.remove(p); } // TODO freynaud problem here.How to handle a window disappearing without loosing the state // of the currently selected page. driver.getPages() may need to become mutable again. // in the normal case, this is the page with the focus that is closed, so loosing the state // is ok. But for the extra window automatically closed ( ie the "there is an app for that // page, downlaod it on itune" page header, the header disappears when driver.get navigates // to a new page. The header disapeearing shouldn't impact the current state. for (WebkitPage p : old) { log.fine("the page " + p + " has been deleted and must be removed from the driver cache"); int currentFocus = driver.getCurrentPageID(); if (p.getPageId() == currentFocus) { log.fine("the page deleted is the one with the focus."); } else { driver.setPages(m.getPages()); } } } sync.signalSimSentPages(); } else { driver.setPages(messagePages); if (messagePages.size() > 0) { if (session != null) { waitForWindowSwitchingAnimation(); } WebkitPage focus = selectPage(driver.getPages()); if (focus != null) { driver.switchTo(focus); } } sync.signalSimSentPages(); } } if (message instanceof ApplicationDataMessage) { //ApplicationDataMessage m = (ApplicationDataMessage)message; } if (message instanceof ApplicationConnectedMessage) { ApplicationConnectedMessage m = (ApplicationConnectedMessage) message; List<WebkitApplication> apps = new ArrayList<WebkitApplication>(); apps.add(m.getApplication()); driver.setApplications(apps); sync.signalSimSentApps(); } }
From source file:org.xwiki.invitation.test.po.InspectInvitationsPage.java
License:Open Source License
public OneMessage getMessageWhere(String columnName, String value) { List<String> columnEntries = new ArrayList<String>(); List<WebElement> column = getTable().getColumn(columnName); for (WebElement cell : column) { if (cell.getText().equals(value)) { // Get the Subject element in the same row and look inside for a link. WebElement link = getUtil().findElementsWithoutWaiting(getDriver(), getTable().getColumn("Subject").get(column.indexOf(cell)), By.tagName("a")).get(0); link.click();/*from w w w . j a va 2 s. c om*/ return null; } columnEntries.add(cell.getText()); } throw new WebDriverException("Could not find message with " + column + " equal to " + value + "\nIn columbn with entries: " + columnEntries.toString()); }
From source file:org.xwiki.invitation.test.po.InvitationFooterElement.java
License:Open Source License
public InspectInvitationsPage inspectAllInvitations() { if (!isAdmin()) { throw new WebDriverException("Inspection as admin impossible because user is not admin."); }//from w ww.j ava2s . c om this.inspectAllAsAdmin.click(); return new InspectInvitationsPage.AsAdmin(); }
From source file:org.xwiki.invitation.test.po.InvitationGuestActionsPage.java
License:Open Source License
/** * @param htmlMessageContent the html message received by the guest containing the link to the accept page * @param action the action to be performed by the guest * @return the corresponding page object * @since 6.3M1//from w w w . j a v a2 s. c o m */ public static InvitationGuestActionsPage gotoPage(String htmlMessageContent, Action action) { int start = htmlMessageContent.indexOf(getUtil().getURL("Invitation", "InvitationGuestActions", "view", "doAction_" + action.toString().toLowerCase())); int end = htmlMessageContent.indexOf("\"", start); getUtil().gotoPage(htmlMessageContent.substring(start, end).replaceAll("&", "&")); InvitationGuestActionsPage page = new InvitationGuestActionsPage(); // Make sure the right messages is displayed otherwise we can't continue. if (action.label != null && !page.getConfirmation().getLabel().equalsIgnoreCase(action.label)) { throw new WebDriverException( "Not on correct page, expecting memo label to say \"" + action.label + "\""); } return new InvitationGuestActionsPage(); }
From source file:org.xwiki.invitation.test.po.InvitationMessageDisplayElement.java
License:Open Source License
public boolean isRecipientValid(String email) { for (WebElement recip : getAllRecipients()) { if (recip.getText().contains(email)) { return recip.getAttribute("class").contains("valid-address"); }// ww w .j a v a 2 s . c om } throw new WebDriverException("Recipient name (" + email + ") not found."); }
From source file:org.xwiki.test.ui.framework.elements.FormElement.java
License:Open Source License
public void setCheckBox(WebElement checkBoxElement, boolean checked) { int x = 0;//from w w w .jav a2s . c om while (checkBoxElement.isSelected() != checked) { checkBoxElement.toggle(); if (x == 100) { throw new WebDriverException( "Unable to set checkbox at " + checkBoxElement.getAttribute("name") + " to " + checked); } x++; } }
From source file:org.xwiki.test.ui.framework.elements.TableElement.java
License:Open Source License
public TableElement(WebElement table) { super();//from w w w . jav a 2 s .c o m if (!table.getTagName().toLowerCase().equals("table")) { throw new WebDriverException("You can only create a TableElement using a <table> web element," + "you passed a <" + table.getTagName() + "> element"); } if (!table.findElements(By.tagName("tbody")).isEmpty()) { this.table = table.findElements(By.tagName("tbody")).get(0); } else { this.table = table; } }
From source file:org.xwiki.test.ui.invitation.elements.InspectInvitationsPage.java
License:Open Source License
public OneMessage getMessageWhere(String columnName, String value) { List<String> columnEntries = new ArrayList<String>(); List<WebElement> column = getTable().getColumn(columnName); for (WebElement cell : column) { if (cell.getText().equals(value)) { // Get the Subject element in the same row and look inside for a link. WebElement link = getTable().getColumn("Subject").get(column.indexOf(cell)) .findElements(By.tagName("a")).get(0); link.click();/*from w w w . ja v a 2 s .co m*/ return null; } columnEntries.add(cell.getText()); } throw new WebDriverException("Could not find message with " + column + " equal to " + value + "\nIn columbn with entries: " + columnEntries.toString()); }
From source file:org.xwiki.test.ui.invitation.elements.InvitationGuestActionsPage.java
License:Open Source License
public InvitationGuestActionsPage(String messageContent, Action action) { confirm = new InvitationActionConfirmationElement(); int start = messageContent.indexOf(getUtil().getURL("Invitation", "InvitationGuestActions", "view", "doAction_" + action.toString().toLowerCase())); int end = messageContent.indexOf("\"", start); getDriver().get(messageContent.substring(start, end).replaceAll("&", "&")); // Make sure the right messages is displayed otherwise we can't continue. if (action.label != null && !confirm.getLabel().equals(action.label)) { throw new WebDriverException( "Not on correct page, expecting memo label to say \"" + action.label + "\""); }/*from w w w . j a v a 2s .c o m*/ }
From source file:org.xwiki.test.ui.po.FormElement.java
License:Open Source License
public void setCheckBox(WebElement checkBoxElement, boolean checked) { int x = 0;/* w w w .j a va2 s. c om*/ while (checkBoxElement.isSelected() != checked) { checkBoxElement.click(); if (x == 100) { throw new WebDriverException( "Unable to set checkbox at " + checkBoxElement.getAttribute("name") + " to " + checked); } x++; } }