List of usage examples for org.openqa.selenium.support.ui ExpectedConditions attributeToBeNotEmpty
public static ExpectedCondition<Boolean> attributeToBeNotEmpty(final WebElement element, final String attribute)
From source file:com.fullteaching.backend.e2e.FullTeachingTestE2E.java
License:Apache License
private boolean checkVideoPlaying(BrowserUser user, WebElement videoElement, String containerQuerySelector) { // Video element should be in 'readyState'='HAVE_ENOUGH_DATA' user.getWaiter().until(ExpectedConditions.attributeToBe(videoElement, "readyState", "4")); // Video should have a valid 'src' value user.getWaiter().until(ExpectedConditions.attributeToBeNotEmpty(videoElement, "src")); // Video should have a srcObject (type MediaStream) with the attribute 'active' to true Assert.assertTrue((boolean) user.runJavascript("return document.querySelector('" + containerQuerySelector + "').getElementsByTagName('video')[0].srcObject.active")); // Video should trigger 'playing' event user.runJavascript("document.querySelector('" + containerQuerySelector + "').getElementsByTagName('video')[0].addEventListener('playing', window.MY_FUNC('" + containerQuerySelector + "'));"); user.getWaiter().until(/* w ww .ja va2 s.c o m*/ ExpectedConditions.textToBePresentInElementLocated(By.id("video-playing-div"), "VIDEO PLAYING")); user.runJavascript("document.body.removeChild(document.getElementById('video-playing-div'))"); return true; }
From source file:com.liferay.faces.test.alloy.issue.FACES_3274Tester.java
License:Open Source License
private void runFaces_3274InputDateTimeTest(BrowserDriver browserDriver, WaitingAsserter waitingAsserter, String inputType, String inputIdSuffix) { navigateToUseCase(browserDriver, inputType, "general"); String showOnButtonInputXpath = getInputDateTimeXpath("button", inputIdSuffix); WebElement showOnButtonInput = browserDriver.findElementByXpath(showOnButtonInputXpath); waitingAsserter.assertTrue(ExpectedConditions .not(ExpectedConditions.attributeToBeNotEmpty(showOnButtonInput, "autocomplete"))); String showOnFocusInputXpath = getInputDateTimeXpath("focus", inputIdSuffix); assertAutocompleteAttributeOff(waitingAsserter, showOnFocusInputXpath); String showOnBothInputXpath = getInputDateTimeXpath("both", inputIdSuffix); assertAutocompleteAttributeOff(waitingAsserter, showOnBothInputXpath); if ("firefox".equals(browserDriver.getBrowserName())) { runFACES_3274Test(browserDriver, waitingAsserter, showOnButtonInputXpath, true); if ("inputDate".equalsIgnoreCase(inputType)) { runFACES_3274Test(browserDriver, waitingAsserter, showOnFocusInputXpath, false); runFACES_3274Test(browserDriver, waitingAsserter, showOnBothInputXpath, false); }//from ww w .ja va2s.c o m } }
From source file:io.openvidu.test.e2e.OpenViduTestAppE2eTest.java
License:Apache License
@Test @DisplayName("Subscribe Unsubscribe") void subscribeUnsubscribeTest() throws Exception { setupBrowser("chrome"); log.info("Subscribe Unsubscribe"); user.getDriver().findElement(By.id("one2one-btn")).click(); user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .publish-checkbox")).click(); user.getDriver().findElements(By.className("join-btn")).forEach(el -> el.sendKeys(Keys.ENTER)); user.getEventManager().waitUntilEventReaches("connectionCreated", 4); user.getEventManager().waitUntilEventReaches("accessAllowed", 1); user.getEventManager().waitUntilEventReaches("streamCreated", 2); user.getEventManager().waitUntilEventReaches("streamPlaying", 2); int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size(); Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, 2, numberOfVideos); Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager() .assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true)); // Global unsubscribe-subscribe WebElement subscriberVideo = user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 video")); WebElement subBtn = user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-btn"))); subBtn.click();/*from w ww.j ava 2 s . c om*/ user.getWaiter().until( ExpectedConditions.not(ExpectedConditions.attributeToBeNotEmpty(subscriberVideo, "srcObject"))); Assert.assertFalse("Subscriber video should not have srcObject defined after unsubscribe", user.getEventManager().hasMediaStream(subscriberVideo, "#openvidu-instance-0")); subBtn.click(); user.getEventManager().waitUntilEventReaches("streamPlaying", 3); numberOfVideos = user.getDriver().findElements(By.tagName("video")).size(); Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, 2, numberOfVideos); Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager() .assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true)); // Video unsubscribe subscriberVideo = user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 video")); Iterable<WebElement> firstVideo = Arrays.asList(subscriberVideo); user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-video-btn"))).click(); Thread.sleep(1000); Assert.assertTrue("Subscriber video was expected to only have audio track", user.getEventManager().assertMediaTracks(firstVideo, true, false)); // Audio unsubscribe user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-audio-btn"))).click(); Thread.sleep(1000); Assert.assertTrue("Subscriber video was expected to not have video or audio tracks", user.getEventManager().assertMediaTracks(firstVideo, false, false)); // Video and audio subscribe user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-video-btn"))).click(); Thread.sleep(1000); Assert.assertTrue("Subscriber video was expected to only have video track", user.getEventManager().assertMediaTracks(firstVideo, false, true)); user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-audio-btn"))).click(); Thread.sleep(1000); Assert.assertTrue("Subscriber video was expected to have audio and video tracks", user.getEventManager().assertMediaTracks(firstVideo, true, true)); gracefullyLeaveParticipants(2); }
From source file:io.openvidu.test.e2e.OpenViduTestAppE2eTest.java
License:Apache License
@Test @DisplayName("Publish Unpublish") void publishUnpublishTest() throws Exception { setupBrowser("chrome"); log.info("Signal message"); user.getDriver().findElement(By.id("auto-join-checkbox")).click(); user.getDriver().findElement(By.id("one2one-btn")).click(); user.getEventManager().waitUntilEventReaches("connectionCreated", 4); user.getEventManager().waitUntilEventReaches("accessAllowed", 2); user.getEventManager().waitUntilEventReaches("streamCreated", 4); user.getEventManager().waitUntilEventReaches("streamPlaying", 4); int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size(); Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, 4, numberOfVideos); Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager() .assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true)); List<WebElement> publishButtons = user.getDriver().findElements(By.className("pub-btn")); for (WebElement el : publishButtons) { el.click();//from ww w . jav a 2s. c o m } user.getEventManager().waitUntilEventReaches("streamDestroyed", 4); for (WebElement video : user.getDriver().findElements(By.tagName("video"))) { user.getWaiter() .until(ExpectedConditions.not(ExpectedConditions.attributeToBeNotEmpty(video, "srcObject"))); Assert.assertFalse("Videos were expected to lack srcObject property", user.getEventManager().hasMediaStream(video, "")); } for (WebElement el : publishButtons) { el.click(); } user.getEventManager().waitUntilEventReaches("streamCreated", 8); user.getEventManager().waitUntilEventReaches("streamPlaying", 8); Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager() .assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true)); gracefullyLeaveParticipants(2); }
From source file:org.eclipse.che.selenium.pageobject.dashboard.organization.OrganizationPage.java
License:Open Source License
public void waitOrganizationName(String name) { redrawUiElementsTimeout.until(ExpectedConditions.attributeToBeNotEmpty(organizationName, "value")); redrawUiElementsTimeout.until((WebDriver driver) -> driver.findElement(By.xpath(Locators.ORGANIZATION_NAME)) .getAttribute("value").equals(name)); }