@Override protected void performWait(FluentWait<WebDriver, Void> wait) { wait.until().element(getLocalPopup()).is().present(); } }.withMessage("Waiting for popup to be not visible")
@When("^I eat (\\d+) cukes$") public void eatCukes(int cukes) throws IOException { waitAjax()/*we just loaded the page*/.until().element(bellyMouth).is().present(); bellyMouth.sendKeys(Integer.toString(cukes)); final File screenshot = new File("target/screenshots/eatCukes.png"); screenshot.getParentFile().mkdirs(); try (final OutputStream os = new FileOutputStream(screenshot)) { os.write(TakesScreenshot.class.cast(browser).getScreenshotAs(OutputType.BYTES)); } waitGui()/*we are already on the page so faster wait cycle*/.until().element(bellyEat).is().present(); bellyEat.click(); }
@Override public void perform() { Graphene.waitGui().until().element(element).is().present(); Utils.triggerJQ((JavascriptExecutor) driver, event.getEventName(), element); } });
protected void checkElementIsPresent(ElementBuilder<?> header) { idInput.clear(); idInput.sendKeys("header2"); updateButton.click(); header.is().not().present(); idInput.clear(); idInput.sendKeys("header"); updateButton.click(); header.is().present(); }
protected void checkElementIsPresent(ElementBuilder<?> header) { idInput.clear(); idInput.sendKeys("header2"); updateButton.click(); header.is().not().present(); idInput.clear(); idInput.sendKeys("header"); updateButton.click(); header.is().present(); }
public void loadPage() { browser.get(Constants.SAMPLE_HTML_PATH); Graphene.waitAjax().until().element(rootElement).is().present(); }
@Test @RunAsClient @InSequence(10) public void testSimpleMessage(@ArquillianResource URL url) throws Exception { // 1. Create our test with a unique channel id. final String channelId = String.valueOf(System.currentTimeMillis()); driver.get(url + "/channelPage.jsp?test-channel-id=" + channelId); // 2. Verify that the server received our channel id and is using it for this tests. WebElement channel = driver.findElement(By.id("channel-id")); assertEquals(channelId, channel.getText()); // 3. The browser waits for the channel to be opened. There is an implicit timeout of 30 seconds if it is not found. Graphene.waitModel(driver).until().element(By.id("opened-" + channelId)).is().present(); // 4. Send a message via channel to the server. WebElement sendButton = driver.findElement(By.id("send-message-button")); sendButton.click(); // 4. Check that we attempted to send a message from the browser to server. Graphene.waitModel(driver).until().element(By.id("last-sent-message-" + channelId)).is().present(); // 5. Now verify that the browser got the ACK from the server. String receivedMsgId = "last-received-message-" + channelId; Graphene.waitModel(driver).until().element(By.id(receivedMsgId)).is().present(); WebElement lastReceived = driver.findElement(By.id(receivedMsgId)); String expectedMsg = "echo-from-server:msg:" + channelId; assertEquals(expectedMsg, lastReceived.getText()); }
@Then("^I should have (\\d+) cukes in my belly$") public void shouldHaveThisMany(final int cukes) { final WebElement element = browser.findElement(xpath("//li[contains(text(), 'The belly ate ')]")); waitAjax().until().element(element).is().present(); assertEquals("The belly ate " + cukes + " cukes!", browser.findElement(xpath("//li[contains(text(), 'The belly ate')]")).getText()); } }
@Override protected void performWait(FluentWait<WebDriver, Void> wait) { wait.until().element(getLocalList()).is().present(); wait.until().element(getGlobalList()).is().not().visible(); } }.withMessage("Waiting for popup to hide.")
@Test public void testElementIsPresent() { idInput.clear(); idInput.sendKeys("header2"); updateButton.click(); Graphene.waitModel(browser).until().element(header).is().not().present(); idInput.clear(); idInput.sendKeys("header"); updateButton.click(); Graphene.waitModel(browser).until().element(header).is().present(); }
@Override public Autocomplete confirm() { // in normal circumstances the confirmation could be done with `ENTER` key, but in WebDriver this causes the form // to be submitted with HTTP, so we need to workaround it boolean selectFirst = advanced().isSelectFirst(); if (selectFirst && !advanced().getSuggestionsElements().isEmpty()) { select();// select the first item } else { // blur the input and focus on it again >>> the change event will be triggered, but we do not lose focus Utils.performUniversalBlur(driver); Graphene.waitModel().until().element(advanced().getInput().advanced().getInputElement()).is().present(); advanced().getInput().advanced().getInputElement().click(); } return RichFacesAutocomplete.this; }
@Test public void testElementIsPresent() { idInput.clear(); idInput.sendKeys("header2"); updateButton.click(); Graphene.waitModel(browser).until().element(header).is().not().present(); idInput.clear(); idInput.sendKeys("header"); updateButton.click(); Graphene.waitModel(browser).until().element(header).is().present(); }
@Test public void testElementIsPresentWithBy() { idInput.clear(); idInput.sendKeys("header2"); updateButton.click(); Graphene.waitModel(browser).until().element(BY_HEADER).is().not().present(); idInput.clear(); idInput.sendKeys("header"); updateButton.click(); Graphene.waitModel(browser).until().element(BY_HEADER).is().present(); }
@Test public void testElementIsPresentWithBy() { idInput.clear(); idInput.sendKeys("header2"); updateButton.click(); Graphene.waitModel(browser).until().element(BY_HEADER).is().not().present(); idInput.clear(); idInput.sendKeys("header"); updateButton.click(); Graphene.waitModel(browser).until().element(BY_HEADER).is().present(); }