How to use WaitUntilAction class of com.consol.citrus.selenium.actions package

Best Citrus code snippet using com.consol.citrus.selenium.actions.WaitUntilAction

Source:SeleniumTestRunnerTest.java Github

copy

Full Screen

...40import com.consol.citrus.selenium.actions.StartBrowserAction;41import com.consol.citrus.selenium.actions.StopBrowserAction;42import com.consol.citrus.selenium.actions.StoreFileAction;43import com.consol.citrus.selenium.actions.SwitchWindowAction;44import com.consol.citrus.selenium.actions.WaitUntilAction;45import com.consol.citrus.selenium.endpoint.SeleniumBrowser;46import com.consol.citrus.selenium.endpoint.SeleniumBrowserConfiguration;47import com.consol.citrus.selenium.endpoint.SeleniumHeaders;48import com.consol.citrus.spi.ReferenceResolver;49import org.mockito.Mockito;50import org.openqa.selenium.Alert;51import org.openqa.selenium.By;52import org.openqa.selenium.WebDriver;53import org.openqa.selenium.WebElement;54import org.openqa.selenium.chrome.ChromeDriver;55import org.openqa.selenium.interactions.Coordinates;56import org.openqa.selenium.interactions.Keyboard;57import org.openqa.selenium.interactions.Mouse;58import org.openqa.selenium.remote.BrowserType;59import org.openqa.selenium.remote.RemoteWebElement;60import org.testng.Assert;61import org.testng.annotations.Test;62import static org.mockito.ArgumentMatchers.anyString;63import static org.mockito.Mockito.verify;64import static org.mockito.Mockito.when;65/**66 * @author Christoph Deppisch67 * @since 2.768 */69public class SeleniumTestRunnerTest extends UnitTestSupport {70 private SeleniumBrowser seleniumBrowser = Mockito.mock(SeleniumBrowser.class);71 private SeleniumBrowserConfiguration seleniumBrowserConfiguration = Mockito.mock(SeleniumBrowserConfiguration.class);72 private ChromeDriver webDriver = Mockito.mock(ChromeDriver.class);73 private ReferenceResolver referenceResolver = Mockito.mock(ReferenceResolver.class);74 private WebElement element = Mockito.mock(WebElement.class);75 private WebElement button = Mockito.mock(WebElement.class);76 private RemoteWebElement link = Mockito.mock(RemoteWebElement.class);77 private WebElement input = Mockito.mock(WebElement.class);78 private WebElement checkbox = Mockito.mock(WebElement.class);79 private WebElement hidden = Mockito.mock(WebElement.class);80 private Alert alert = Mockito.mock(Alert.class);81 private WebDriver.Navigation navigation = Mockito.mock(WebDriver.Navigation.class);82 private WebDriver.TargetLocator locator = Mockito.mock(WebDriver.TargetLocator.class);83 private WebDriver.Options options = Mockito.mock(WebDriver.Options.class);84 private Mouse mouse = Mockito.mock(Mouse.class);85 private Keyboard keyboard = Mockito.mock(Keyboard.class);86 private Coordinates coordinates = Mockito.mock(Coordinates.class);87 @Test88 public void testSeleniumBuilder() {89 when(referenceResolver.resolve(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));90 when(referenceResolver.resolve(TestActionListeners.class)).thenReturn(new TestActionListeners());91 when(referenceResolver.resolveAll(SequenceBeforeTest.class)).thenReturn(new HashMap<>());92 when(referenceResolver.resolveAll(SequenceAfterTest.class)).thenReturn(new HashMap<>());93 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(seleniumBrowserConfiguration);94 when(seleniumBrowserConfiguration.getBrowserType()).thenReturn(BrowserType.CHROME);95 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);96 when(seleniumBrowser.getName()).thenReturn("mockBrowser");97 when(referenceResolver.resolve("mockBrowser", SeleniumBrowser.class)).thenReturn(seleniumBrowser);98 when(webDriver.navigate()).thenReturn(navigation);99 when(webDriver.manage()).thenReturn(options);100 when(webDriver.switchTo()).thenReturn(locator);101 when(locator.alert()).thenReturn(alert);102 when(alert.getText()).thenReturn("Hello!");103 when(webDriver.findElement(By.id("header"))).thenReturn(element);104 when(element.getTagName()).thenReturn("h1");105 when(element.isEnabled()).thenReturn(true);106 when(element.isDisplayed()).thenReturn(true);107 when(webDriver.findElement(By.linkText("Click Me!"))).thenReturn(link);108 when(link.getTagName()).thenReturn("a");109 when(link.isEnabled()).thenReturn(true);110 when(link.isDisplayed()).thenReturn(true);111 when(webDriver.findElement(By.linkText("Hover Me!"))).thenReturn(link);112 when(webDriver.getMouse()).thenReturn(mouse);113 when(webDriver.getKeyboard()).thenReturn(keyboard);114 when(link.getCoordinates()).thenReturn(coordinates);115 when(webDriver.findElement(By.name("username"))).thenReturn(input);116 when(input.getTagName()).thenReturn("input");117 when(input.isEnabled()).thenReturn(true);118 when(input.isDisplayed()).thenReturn(true);119 when(webDriver.findElement(By.name("hiddenButton"))).thenReturn(hidden);120 when(hidden.getTagName()).thenReturn("input");121 when(hidden.isEnabled()).thenReturn(true);122 when(hidden.isDisplayed()).thenReturn(false);123 when(webDriver.findElement(By.xpath("//input[@type='checkbox']"))).thenReturn(checkbox);124 when(checkbox.getTagName()).thenReturn("input");125 when(checkbox.isEnabled()).thenReturn(true);126 when(checkbox.isDisplayed()).thenReturn(true);127 when(checkbox.isSelected()).thenReturn(false);128 when(webDriver.executeScript(anyString())).thenReturn(Collections.singletonList("This went wrong!"));129 when(webDriver.findElement(By.className("btn"))).thenReturn(button);130 when(button.getTagName()).thenReturn("button");131 when(button.isEnabled()).thenReturn(false);132 when(button.isDisplayed()).thenReturn(false);133 when(button.getText()).thenReturn("Click Me!");134 when(button.getAttribute("type")).thenReturn("submit");135 when(button.getCssValue("color")).thenReturn("red");136 when(seleniumBrowser.getStoredFile("file.txt")).thenReturn("file.txt");137 Set<String> windows = new HashSet<>();138 windows.add("last_window");139 windows.add("new_window");140 when(webDriver.getWindowHandles()).thenReturn(Collections.singleton("last_window")).thenReturn(windows);141 when(webDriver.getWindowHandle()).thenReturn("last_window");142 context.setVariable("cssClass", "btn");143 context.setReferenceResolver(referenceResolver);144 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), context) {145 @Override146 public void execute() {147 selenium(action -> action.start(seleniumBrowser));148 selenium(action -> action.navigate("http://localhost:9090"));149 selenium(action -> action.find().element(By.id("header")));150 selenium(action -> action.find().element("class-name", "${cssClass}")151 .tagName("button")152 .enabled(false)153 .displayed(false)154 .text("Click Me!")155 .style("color", "red")156 .attribute("type", "submit"));157 selenium(action -> action.click().element(By.linkText("Click Me!")));158 selenium(action -> action.hover().element(By.linkText("Hover Me!")));159 selenium(action -> action.setInput("Citrus").element(By.name("username")));160 selenium(action -> action.checkInput(false).element(By.xpath("//input[@type='checkbox']")));161 selenium(action -> action.javascript("alert('Hello!')")162 .errors("This went wrong!"));163 selenium(action -> action.alert().text("Hello!").accept());164 selenium(SeleniumActionBuilder::clearCache);165 selenium(action -> action.store("classpath:download/file.txt"));166 selenium(action -> action.getStored("file.txt"));167 selenium(action -> action.open().window("my_window"));168 selenium(action -> action.focus().window("my_window"));169 selenium(action -> action.close().window("my_window"));170 selenium(action -> action.waitUntil().hidden().element(By.name("hiddenButton")));171 selenium(action -> action.stop(seleniumBrowser));172 }173 };174 TestCase test = builder.getTestCase();175 int actionIndex = 0;176 Assert.assertEquals(test.getActionCount(), 18);177 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), StartBrowserAction.class);178 StartBrowserAction startBrowserAction = (StartBrowserAction) test.getActions().get(actionIndex++);179 Assert.assertEquals(startBrowserAction.getName(), "selenium:start");180 Assert.assertNotNull(startBrowserAction.getBrowser());181 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), NavigateAction.class);182 NavigateAction navigateAction = (NavigateAction) test.getActions().get(actionIndex++);183 Assert.assertEquals(navigateAction.getName(), "selenium:navigate");184 Assert.assertEquals(navigateAction.getPage(), "http://localhost:9090");185 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), FindElementAction.class);186 FindElementAction findElementAction = (FindElementAction) test.getActions().get(actionIndex++);187 Assert.assertEquals(findElementAction.getName(), "selenium:find");188 Assert.assertEquals(findElementAction.getBy(), By.id("header"));189 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), FindElementAction.class);190 findElementAction = (FindElementAction) test.getActions().get(actionIndex++);191 Assert.assertEquals(findElementAction.getName(), "selenium:find");192 Assert.assertEquals(findElementAction.getProperty(), "class-name");193 Assert.assertEquals(findElementAction.getPropertyValue(), "${cssClass}");194 Assert.assertEquals(findElementAction.getTagName(), "button");195 Assert.assertEquals(findElementAction.getText(), "Click Me!");196 Assert.assertFalse(findElementAction.isEnabled());197 Assert.assertFalse(findElementAction.isDisplayed());198 Assert.assertEquals(findElementAction.getStyles().size(), 1L);199 Assert.assertEquals(findElementAction.getStyles().get("color"), "red");200 Assert.assertEquals(findElementAction.getAttributes().size(), 1L);201 Assert.assertEquals(findElementAction.getAttributes().get("type"), "submit");202 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), ClickAction.class);203 ClickAction clickAction = (ClickAction) test.getActions().get(actionIndex++);204 Assert.assertEquals(clickAction.getName(), "selenium:click");205 Assert.assertEquals(clickAction.getBy(), By.linkText("Click Me!"));206 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), HoverAction.class);207 HoverAction hoverAction = (HoverAction) test.getActions().get(actionIndex++);208 Assert.assertEquals(hoverAction.getName(), "selenium:hover");209 Assert.assertEquals(hoverAction.getBy(), By.linkText("Hover Me!"));210 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), SetInputAction.class);211 SetInputAction setInputAction = (SetInputAction) test.getActions().get(actionIndex++);212 Assert.assertEquals(setInputAction.getName(), "selenium:set-input");213 Assert.assertEquals(setInputAction.getBy(), By.name("username"));214 Assert.assertEquals(setInputAction.getValue(), "Citrus");215 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), CheckInputAction.class);216 CheckInputAction checkInputAction = (CheckInputAction) test.getActions().get(actionIndex++);217 Assert.assertEquals(checkInputAction.getName(), "selenium:check-input");218 Assert.assertEquals(checkInputAction.getBy(), By.xpath("//input[@type='checkbox']"));219 Assert.assertFalse(checkInputAction.isChecked());220 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), JavaScriptAction.class);221 JavaScriptAction javaScriptAction = (JavaScriptAction) test.getActions().get(actionIndex++);222 Assert.assertEquals(javaScriptAction.getName(), "selenium:javascript");223 Assert.assertEquals(javaScriptAction.getScript(), "alert('Hello!')");224 Assert.assertEquals(javaScriptAction.getExpectedErrors().size(), 1L);225 Assert.assertEquals(javaScriptAction.getExpectedErrors().get(0), "This went wrong!");226 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), AlertAction.class);227 AlertAction alertAction = (AlertAction) test.getActions().get(actionIndex++);228 Assert.assertEquals(alertAction.getName(), "selenium:alert");229 Assert.assertEquals(alertAction.getText(), "Hello!");230 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), ClearBrowserCacheAction.class);231 ClearBrowserCacheAction clearBrowserCacheAction = (ClearBrowserCacheAction) test.getActions().get(actionIndex++);232 Assert.assertEquals(clearBrowserCacheAction.getName(), "selenium:clear-cache");233 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), StoreFileAction.class);234 StoreFileAction storeFileAction = (StoreFileAction) test.getActions().get(actionIndex++);235 Assert.assertEquals(storeFileAction.getName(), "selenium:store-file");236 Assert.assertEquals(storeFileAction.getFilePath(), "classpath:download/file.txt");237 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), GetStoredFileAction.class);238 GetStoredFileAction getStoredFileAction = (GetStoredFileAction) test.getActions().get(actionIndex++);239 Assert.assertEquals(getStoredFileAction.getName(), "selenium:get-stored-file");240 Assert.assertEquals(getStoredFileAction.getFileName(), "file.txt");241 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), OpenWindowAction.class);242 OpenWindowAction openWindowAction = (OpenWindowAction) test.getActions().get(actionIndex++);243 Assert.assertEquals(openWindowAction.getName(), "selenium:open-window");244 Assert.assertEquals(openWindowAction.getWindowName(), "my_window");245 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), SwitchWindowAction.class);246 SwitchWindowAction switchWindowAction = (SwitchWindowAction) test.getActions().get(actionIndex++);247 Assert.assertEquals(switchWindowAction.getName(), "selenium:switch-window");248 Assert.assertEquals(switchWindowAction.getWindowName(), "my_window");249 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), CloseWindowAction.class);250 CloseWindowAction closeWindowAction = (CloseWindowAction) test.getActions().get(actionIndex++);251 Assert.assertEquals(closeWindowAction.getName(), "selenium:close-window");252 Assert.assertEquals(closeWindowAction.getWindowName(), "my_window");253 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), WaitUntilAction.class);254 WaitUntilAction waitUntilAction = (WaitUntilAction) test.getActions().get(actionIndex++);255 Assert.assertEquals(waitUntilAction.getName(), "selenium:wait");256 Assert.assertEquals(waitUntilAction.getBy(), By.name("hiddenButton"));257 Assert.assertEquals(waitUntilAction.getCondition(), "hidden");258 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), StopBrowserAction.class);259 StopBrowserAction stopBrowserAction = (StopBrowserAction) test.getActions().get(actionIndex);260 Assert.assertEquals(stopBrowserAction.getName(), "selenium:stop");261 Assert.assertNotNull(stopBrowserAction.getBrowser());262 Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_ALERT_TEXT), "Hello!");263 Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_DOWNLOAD_FILE), "file.txt");264 Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW), "last_window");265 Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW), "new_window");266 Assert.assertEquals(context.getVariable("my_window"), "new_window");267 verify(alert).accept();268 verify(options).deleteAllCookies();...

Full Screen

Full Screen

Source:SeleniumTestDesignerTest.java Github

copy

Full Screen

...30import com.consol.citrus.selenium.actions.StartBrowserAction;31import com.consol.citrus.selenium.actions.StopBrowserAction;32import com.consol.citrus.selenium.actions.StoreFileAction;33import com.consol.citrus.selenium.actions.SwitchWindowAction;34import com.consol.citrus.selenium.actions.WaitUntilAction;35import com.consol.citrus.selenium.endpoint.SeleniumBrowser;36import com.consol.citrus.dsl.UnitTestSupport;37import org.mockito.Mockito;38import org.openqa.selenium.By;39import org.testng.Assert;40import org.testng.annotations.Test;41/**42 * @author Christoph Deppisch43 * @since 2.744 */45public class SeleniumTestDesignerTest extends UnitTestSupport {46 private SeleniumBrowser seleniumBrowser = Mockito.mock(SeleniumBrowser.class);47 @Test48 public void testSeleniumBuilder() {49 MockTestDesigner builder = new MockTestDesigner(context) {50 @Override51 public void configure() {52 selenium().start(seleniumBrowser);53 selenium().navigate("http://localhost:9090");54 selenium().find().element(By.id("target"));55 selenium().find().element("class-name", "${cssClass}")56 .tagName("button")57 .enabled(false)58 .displayed(false)59 .text("Click Me!")60 .style("color", "red")61 .attribute("type", "submit");62 selenium().click().element(By.linkText("Click Me!"));63 selenium().hover().element(By.linkText("Hover Me!"));64 selenium().setInput("Citrus").element(By.name("username"));65 selenium().checkInput(false).element(By.xpath("//input[@type='checkbox']"));66 selenium().javascript("alert('Hello!')")67 .errors("This went wrong!");68 selenium().alert().text("Hello!").accept();69 selenium().clearCache();70 selenium().store("classpath:download/file.txt");71 selenium().getStored("file.txt");72 selenium().open().window("my_window");73 selenium().focus().window("my_window");74 selenium().close().window("my_window");75 selenium().waitUntil().hidden().element(By.name("hiddenButton"));76 selenium().stop();77 }78 };79 builder.configure();80 TestCase test = builder.getTestCase();81 int actionIndex = 0;82 Assert.assertEquals(test.getActionCount(), 18);83 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), StartBrowserAction.class);84 StartBrowserAction startBrowserAction = (StartBrowserAction) test.getActions().get(actionIndex++);85 Assert.assertEquals(startBrowserAction.getName(), "selenium:start");86 Assert.assertNotNull(startBrowserAction.getBrowser());87 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), NavigateAction.class);88 NavigateAction navigateAction = (NavigateAction) test.getActions().get(actionIndex++);89 Assert.assertEquals(navigateAction.getName(), "selenium:navigate");90 Assert.assertEquals(navigateAction.getPage(), "http://localhost:9090");91 Assert.assertNull(navigateAction.getBrowser());92 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), FindElementAction.class);93 FindElementAction findElementAction = (FindElementAction) test.getActions().get(actionIndex++);94 Assert.assertEquals(findElementAction.getName(), "selenium:find");95 Assert.assertEquals(findElementAction.getBy(), By.id("target"));96 Assert.assertNull(findElementAction.getBrowser());97 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), FindElementAction.class);98 findElementAction = (FindElementAction) test.getActions().get(actionIndex++);99 Assert.assertEquals(findElementAction.getName(), "selenium:find");100 Assert.assertEquals(findElementAction.getProperty(), "class-name");101 Assert.assertEquals(findElementAction.getPropertyValue(), "${cssClass}");102 Assert.assertEquals(findElementAction.getTagName(), "button");103 Assert.assertEquals(findElementAction.getText(), "Click Me!");104 Assert.assertFalse(findElementAction.isEnabled());105 Assert.assertFalse(findElementAction.isDisplayed());106 Assert.assertEquals(findElementAction.getStyles().size(), 1L);107 Assert.assertEquals(findElementAction.getStyles().get("color"), "red");108 Assert.assertEquals(findElementAction.getAttributes().size(), 1L);109 Assert.assertEquals(findElementAction.getAttributes().get("type"), "submit");110 Assert.assertNull(findElementAction.getBrowser());111 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), ClickAction.class);112 ClickAction clickAction = (ClickAction) test.getActions().get(actionIndex++);113 Assert.assertEquals(clickAction.getName(), "selenium:click");114 Assert.assertEquals(clickAction.getBy(), By.linkText("Click Me!"));115 Assert.assertNull(findElementAction.getBrowser());116 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), HoverAction.class);117 HoverAction hoverAction = (HoverAction) test.getActions().get(actionIndex++);118 Assert.assertEquals(hoverAction.getName(), "selenium:hover");119 Assert.assertEquals(hoverAction.getBy(), By.linkText("Hover Me!"));120 Assert.assertNull(findElementAction.getBrowser());121 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), SetInputAction.class);122 SetInputAction setInputAction = (SetInputAction) test.getActions().get(actionIndex++);123 Assert.assertEquals(setInputAction.getName(), "selenium:set-input");124 Assert.assertEquals(setInputAction.getBy(), By.name("username"));125 Assert.assertEquals(setInputAction.getValue(), "Citrus");126 Assert.assertNull(findElementAction.getBrowser());127 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), CheckInputAction.class);128 CheckInputAction checkInputAction = (CheckInputAction) test.getActions().get(actionIndex++);129 Assert.assertEquals(checkInputAction.getName(), "selenium:check-input");130 Assert.assertEquals(checkInputAction.getBy(), By.xpath("//input[@type='checkbox']"));131 Assert.assertFalse(checkInputAction.isChecked());132 Assert.assertNull(findElementAction.getBrowser());133 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), JavaScriptAction.class);134 JavaScriptAction javaScriptAction = (JavaScriptAction) test.getActions().get(actionIndex++);135 Assert.assertEquals(javaScriptAction.getName(), "selenium:javascript");136 Assert.assertEquals(javaScriptAction.getScript(), "alert('Hello!')");137 Assert.assertEquals(javaScriptAction.getExpectedErrors().size(), 1L);138 Assert.assertEquals(javaScriptAction.getExpectedErrors().get(0), "This went wrong!");139 Assert.assertNull(findElementAction.getBrowser());140 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), AlertAction.class);141 AlertAction alertAction = (AlertAction) test.getActions().get(actionIndex++);142 Assert.assertEquals(alertAction.getName(), "selenium:alert");143 Assert.assertEquals(alertAction.getText(), "Hello!");144 Assert.assertNull(findElementAction.getBrowser());145 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), ClearBrowserCacheAction.class);146 ClearBrowserCacheAction clearBrowserCacheAction = (ClearBrowserCacheAction) test.getActions().get(actionIndex++);147 Assert.assertEquals(clearBrowserCacheAction.getName(), "selenium:clear-cache");148 Assert.assertNull(findElementAction.getBrowser());149 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), StoreFileAction.class);150 StoreFileAction storeFileAction = (StoreFileAction) test.getActions().get(actionIndex++);151 Assert.assertEquals(storeFileAction.getName(), "selenium:store-file");152 Assert.assertEquals(storeFileAction.getFilePath(), "classpath:download/file.txt");153 Assert.assertNull(findElementAction.getBrowser());154 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), GetStoredFileAction.class);155 GetStoredFileAction getStoredFileAction = (GetStoredFileAction) test.getActions().get(actionIndex++);156 Assert.assertEquals(getStoredFileAction.getName(), "selenium:get-stored-file");157 Assert.assertEquals(getStoredFileAction.getFileName(), "file.txt");158 Assert.assertNull(findElementAction.getBrowser());159 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), OpenWindowAction.class);160 OpenWindowAction openWindowAction = (OpenWindowAction) test.getActions().get(actionIndex++);161 Assert.assertEquals(openWindowAction.getName(), "selenium:open-window");162 Assert.assertEquals(openWindowAction.getWindowName(), "my_window");163 Assert.assertNull(findElementAction.getBrowser());164 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), SwitchWindowAction.class);165 SwitchWindowAction switchWindowAction = (SwitchWindowAction) test.getActions().get(actionIndex++);166 Assert.assertEquals(switchWindowAction.getName(), "selenium:switch-window");167 Assert.assertEquals(switchWindowAction.getWindowName(), "my_window");168 Assert.assertNull(findElementAction.getBrowser());169 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), CloseWindowAction.class);170 CloseWindowAction closeWindowAction = (CloseWindowAction) test.getActions().get(actionIndex++);171 Assert.assertEquals(closeWindowAction.getName(), "selenium:close-window");172 Assert.assertEquals(closeWindowAction.getWindowName(), "my_window");173 Assert.assertNull(findElementAction.getBrowser());174 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), WaitUntilAction.class);175 WaitUntilAction waitUntilAction = (WaitUntilAction) test.getActions().get(actionIndex++);176 Assert.assertEquals(waitUntilAction.getName(), "selenium:wait");177 Assert.assertEquals(waitUntilAction.getBy(), By.name("hiddenButton"));178 Assert.assertEquals(waitUntilAction.getCondition(), "hidden");179 Assert.assertNull(findElementAction.getBrowser());180 Assert.assertEquals(test.getActions().get(actionIndex).getClass(), StopBrowserAction.class);181 StopBrowserAction stopBrowserAction = (StopBrowserAction) test.getActions().get(actionIndex);182 Assert.assertEquals(stopBrowserAction.getName(), "selenium:stop");183 Assert.assertNull(stopBrowserAction.getBrowser());184 }185}...

Full Screen

Full Screen

Source:SeleniumActionBuilder.java Github

copy

Full Screen

...20import com.consol.citrus.selenium.actions.StartBrowserAction;21import com.consol.citrus.selenium.actions.StopBrowserAction;22import com.consol.citrus.selenium.actions.StoreFileAction;23import com.consol.citrus.selenium.actions.SwitchWindowAction;24import com.consol.citrus.selenium.actions.WaitUntilAction;25import com.consol.citrus.selenium.endpoint.SeleniumBrowser;26import com.consol.citrus.selenium.model.WebPage;27import com.consol.citrus.util.FileUtils;28import org.springframework.core.io.Resource;29/**30 * @author Christoph Deppisch31 */32public class SeleniumActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder<SeleniumAction> {33 private final com.consol.citrus.selenium.actions.SeleniumActionBuilder delegate = new com.consol.citrus.selenium.actions.SeleniumActionBuilder();34 public SeleniumActionBuilder browser(SeleniumBrowser seleniumBrowser) {35 delegate.browser(seleniumBrowser);36 return this;37 }38 public StartBrowserAction.Builder start() {39 return delegate.start();40 }41 public StartBrowserAction.Builder start(SeleniumBrowser seleniumBrowser) {42 return delegate.start(seleniumBrowser);43 }44 public StopBrowserAction.Builder stop() {45 return delegate.stop();46 }47 public StopBrowserAction.Builder stop(SeleniumBrowser seleniumBrowser) {48 return delegate.stop(seleniumBrowser);49 }50 public AlertAction.Builder alert() {51 return delegate.alert();52 }53 public NavigateAction.Builder navigate(String page) {54 return delegate.navigate(page);55 }56 public PageAction.Builder page(WebPage page) {57 return delegate.page(page);58 }59 public PageAction.Builder page(Class<? extends WebPage> pageType) {60 return delegate.page(pageType);61 }62 public FindElementAction.Builder find() {63 return delegate.find();64 }65 public DropDownSelectAction.Builder select(String option) {66 return delegate.select(option);67 }68 public DropDownSelectAction.Builder select(String ... options) {69 return delegate.select(options);70 }71 public SetInputAction.Builder setInput(String value) {72 return delegate.setInput(value);73 }74 public CheckInputAction.Builder checkInput(boolean checked) {75 return delegate.checkInput(checked);76 }77 public ClickAction.Builder click() {78 return delegate.click();79 }80 public HoverAction.Builder hover() {81 return delegate.hover();82 }83 public ClearBrowserCacheAction.Builder clearCache() {84 return delegate.clearCache();85 }86 public MakeScreenshotAction.Builder screenshot() {87 return delegate.screenshot();88 }89 public MakeScreenshotAction.Builder screenshot(String outputDir) {90 return delegate.screenshot(outputDir);91 }92 public StoreFileAction.Builder store(String filePath) {93 return delegate.store(filePath);94 }95 public GetStoredFileAction.Builder getStored(String fileName) {96 return delegate.getStored(fileName);97 }98 public WaitUntilAction.Builder waitUntil() {99 return delegate.waitUntil();100 }101 public JavaScriptAction.Builder javascript(String script) {102 return delegate.javascript(script);103 }104 public JavaScriptAction.Builder javascript(Resource script) {105 return javascript(script, FileUtils.getDefaultCharset());106 }107 public JavaScriptAction.Builder javascript(Resource scriptResource, Charset charset) {108 return delegate.javascript(scriptResource, charset);109 }110 public OpenWindowAction.Builder open() {111 return delegate.open();112 }...

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.annotations.CitrusTest;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import com.consol.citrus.selenium.actions.ClickAction;4import com.consol.citrus.selenium.actions.NavigateAction;5import com.consol.citrus.selenium.actions.WaitUntilAction;6import org.openqa.selenium.By;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.support.ui.ExpectedConditions;9import org.testng.annotations.Test;10public class WaitUntilActionTest extends TestNGCitrusTestRunner {11 public void waitUntilAction() {12 selenium("chrome").actions().click(By.name("q"));13 selenium("chrome").actions().sendKeys("citrus");14 selenium("chrome").actions().sendKeys("{ENTER}");15 selenium("chrome").actions().waitUntil(ExpectedConditions.visibilityOfElementLocated(By.id("result-stats")));16 selenium("chrome").actions().click(By.id("resul

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.By;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.support.ui.ExpectedConditions;6import org.openqa.selenium.support.ui.WebDriverWait;7import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;8import com.consol.citrus.selenium.actions.WaitUntilAction;9public class 3 extends TestNGCitrusTestDesigner {10 WebDriver driver = new ChromeDriver();11 public void run() {12 WaitUntilAction waitUntilAction = new WaitUntilAction();13 waitUntilAction.setDriver(driver);14 waitUntilAction.setWait(new WebDriverWait(driver, 5));15 waitUntilAction.setCondition(ExpectedConditions.visibilityOfElementLocated(By.id("id")));16 waitUntilAction.setElement(driver.findElement(By.id("id")));17 waitUntilAction.execute(context);18 }19}20import org.openqa.selenium.By;21import org.openqa.selenium.WebDriver;22import org.openqa.selenium.WebElement;23import org.openqa.selenium.chrome.ChromeDriver;24import org.openqa.selenium.support.ui.ExpectedConditions;25import org.openqa.selenium.support.ui.WebDriverWait;26import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;27import com.consol.citrus.selenium.actions.WaitUntilAction;28public class 4 extends TestNGCitrusTestDesigner {29 WebDriver driver = new ChromeDriver();30 public void run() {31 WaitUntilAction waitUntilAction = new WaitUntilAction();32 waitUntilAction.setDriver(driver);33 waitUntilAction.setWait(new WebDriverWait(driver, 5));34 waitUntilAction.setCondition(ExpectedConditions.visibilityOfElementLocated(By.id("id")));35 waitUntilAction.setElement(driver.findElement(By.id("id")));36 waitUntilAction.execute(context);37 }38}39import org.openqa.selenium.By;40import org.openqa.selenium.WebDriver;41import org.openqa.selenium.WebElement;42import org.openqa.selenium.chrome.ChromeDriver;43import org.openqa.selenium.support.ui.ExpectedConditions;44import org.openqa.selenium.support.ui.WebDriverWait;45import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;46import com.consol.citrus.selenium.actions.WaitUntilAction;47public class 5 extends TestNGCitrusTestDesigner {

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;2import com.consol.citrus.selenium.actions.WaitUntilAction;3import com.consol.citrus.selenium.model.WaitCondition;4import org.openqa.selenium.By;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.support.ui.ExpectedConditions;7import org.testng.annotations.Test;8public class WaitUntilActionTest extends TestNGCitrusTestDesigner {9 public void configure() {10 selenium().start();11 selenium().navigate("${url}");12 selenium().click(By.name("q"));13 WaitCondition condition = new WaitCondition();14 condition.setCondition(ExpectedConditions.visibilityOfElementLocated(By.name("btnK")));15 WaitUntilAction waitUntilAction = new WaitUntilAction();16 waitUntilAction.setCondition(condition);17 waitUntilAction.setTimeout(1000L);18 waitUntilAction.setPollingInterval(100L);19 selenium().execute(waitUntilAction);20 selenium().type(By.name("q"), "Citrus");21 selenium().click(By.name("btnK"));22 condition = new WaitCondition();23 condition.setCondition(ExpectedConditions.visibilityOf(element));24 waitUntilAction = new WaitUntilAction();25 waitUntilAction.setCondition(condition);26 waitUntilAction.setTimeout(1000L);27 waitUntilAction.setPollingInterval(100L);28 selenium().execute(waitUntilAction);29 selenium().stop();30 }31}32import com.consol.citrus.dsl.testng.TestNGCitrusTest33import com.consol.citrus.selenium.actions.WaitUntilAction34import com.consol.citrus.selenium.model.WaitCondition35import org.openqa.selenium.By36import org.openqa.selenium.support.ui.ExpectedConditions

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1public class WaitUntilActionTest {2 public void waitUntilTest() {3 MockTestRunner runner = new MockTestRunner();4 WaitUntilAction waitUntilAction = new WaitUntilAction();5 waitUntilAction.setCondition("elementPresent");6 waitUntilAction.setCondition("elementPresent");7 runner.run(waitUntilAction);8 }9}10public class WaitUntilActionTest {11 public void waitUntilTest() {12 MockTestRunner runner = new MockTestRunner();13 WaitUntilAction waitUntilAction = new WaitUntilAction();14 waitUntilAction.setCondition("elementPresent");15 waitUntilAction.setCondition("elementPresent");16 runner.run(waitUntilAction);17 }18}19public class WaitUntilActionTest {20 public void waitUntilTest() {21 MockTestRunner runner = new MockTestRunner();22 WaitUntilAction waitUntilAction = new WaitUntilAction();23 waitUntilAction.setCondition("elementPresent");24 waitUntilAction.setCondition("elementPresent");25 runner.run(waitUntilAction);26 }27}28public class WaitUntilActionTest {29 public void waitUntilTest() {30 MockTestRunner runner = new MockTestRunner();31 WaitUntilAction waitUntilAction = new WaitUntilAction();32 waitUntilAction.setCondition("elementPresent");33 waitUntilAction.setCondition("elementPresent");

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1package com.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import org.testng.annotations.Test;4public class WaitUntil extends TestNGCitrusTestRunner {5 public void waitUntil() {6 selenium().element(selenium().byId("lst-ib")).type("Selenium");7 selenium().element(selenium().byName("btnK")).click();8 selenium().waitUntil(selenium().element(selenium().byLinkText("Selenium - Web Browser Automation")).isPresent());9 }10}11package com.citrus;12import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;13import org.testng.annotations.Test;14public class Wait extends TestNGCitrusTestRunner {15 public void waitUntil() {16 selenium().element(selenium().byId("lst-ib")).type("Selenium");17 selenium().element(selenium().byName("btnK")).click();18 selenium().wait(5000);19 }20}21package com.citrus;22import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;23import org.testng.annotations.Test;24public class SwitchTo extends TestNGCitrusTestRunner {25 public void switchTo() {26 selenium().element(selenium().byId("lst-ib")).type("Selenium");27 selenium().element(selenium().byName("btnK")).click();28 selenium().switchTo().window(1);29 }30}31package com.citrus;32import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;33import org.testng.annotations.Test;34public class SwitchToFrame extends TestNGCitrusTestRunner {35 public void switchToFrame() {36 selenium().element(selenium().byId("lst-ib")).type("

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.demo;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.selenium.endpoint.SeleniumBrowser;5import com.consol.citrus.selenium.model.SeleniumHeaders;6import org.openqa.selenium.By;7import org.springframework.beans.factory.annotation.Autowired;8import org.springframework.beans.factory.annotation.Qualifier;9import org.testng.annotations.Test;10public class WaitUntilActionJavaIT extends TestNGCitrusTestRunner {11 @Qualifier("seleniumBrowser")12 private SeleniumBrowser seleniumBrowser;13 public void waitUntilAction() {14 variable("elementId", "lst-ib");15 selenium().waitUntil()16 .element(By.xpath("${elementXpath}"))17 .visible()18 .timeout(30000L);19 selenium().waitUntil()20 .element(By.id("${elementId}"))21 .visible()22 .timeout(30000L);23 selenium().waitUntil()24 .element(By.id("${elementId}"))25 .visible()26 .timeout(30000L)27 .header(SeleniumHeaders.SELENIUM_BROWSER, seleniumBrowser);28 selenium().waitUntil()29 .element(By.id("${elementId}"))30 .visible()31 .timeout(30000L)32 .header(SeleniumHeaders.SELENIUM_BROWSER, seleniumBrowser)33 .header(SeleniumHeaders.SELENIUM_WAIT_STRATEGY, "polling");34 }35}

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.selenium.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.selenium.endpoint.SeleniumBrowser;4import com.consol.citrus.selenium.endpoint.SeleniumHeaders;5import org.openqa.selenium.By;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.support.ui.ExpectedConditions;8import org.openqa.selenium.support.ui.WebDriverWait;9public class WaitUntilAction extends AbstractSeleniumAction {10 private final By locator;11 private final boolean visible;12 private final boolean invisible;13 private final boolean present;14 private final boolean absent;15 private final boolean clickable;16 private final boolean selected;17 private final boolean unselected;18 private final boolean enabled;19 private final boolean disabled;20 private final boolean stale;21 private final boolean notStale;22 private final boolean displayed;23 private final boolean notDisplayed;24 private final long timeout;25 private final long pollingInterval;26 public WaitUntilAction(Builder builder) {27 super("wait", builder);28 this.locator = builder.locator;29 this.visible = builder.visible;30 this.invisible = builder.invisible;31 this.present = builder.present;32 this.absent = builder.absent;33 this.clickable = builder.clickable;34 this.selected = builder.selected;35 this.unselected = builder.unselected;36 this.enabled = builder.enabled;37 this.disabled = builder.disabled;38 this.stale = builder.stale;39 this.notStale = builder.notStale;40 this.displayed = builder.displayed;41 this.notDisplayed = builder.notDisplayed;

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1public void testWaitUntilAction() {2 selenium().start();3 selenium().waitUntil(element().name("search"), visibility(), 5000L);4 selenium().type(element().name("search"), "Citrus");5 selenium().click(element().name("search-button"));6 selenium().stop();7}8public void testWaitUntilAction() {9 selenium().start();10 selenium().waitUntil(element().name("search"), visibility(), 5000L);11 selenium().type(element().name("search"), "Citrus");12 selenium().click(element().name("search-button"));13 selenium().stop();14}15public void testWaitUntilAction() {16 selenium().start();17 selenium().waitUntil(element().name("search"), visibility(), 5000L);18 selenium().type(element().name("search"), "Citrus");19 selenium().click(element().name("search-button"));20 selenium().stop();21}22public void testWaitUntilAction() {23 selenium().start();24 selenium().waitUntil(element().name("search"), visibility(), 5000L);25 selenium().type(element().name("search"), "Citrus");26 selenium().click(element().name("search-button"));27 selenium().stop();28}29public void testWaitUntilAction() {30 selenium().start();31 selenium().waitUntil(element().name

Full Screen

Full Screen

WaitUntilAction

Using AI Code Generation

copy

Full Screen

1public void testWaitUntilAction(){2 selenium("selenium").actions().waitUntil("selenium").element("css=div#div1").text().equalTo("Hello");3}4public void testWaitUntilAction(){5 selenium("selenium").actions().waitUntil("selenium").element("css=div#div1").text().equalTo("Hello");6}7public void testWaitUntilAction(){8 selenium("selenium").actions().waitUntil("selenium").element("css=div#div1").text().equalTo("Hello");9}10public void testWaitUntilAction(){11 selenium("selenium").actions().waitUntil("selenium").element("css=div#div1").text().equalTo("Hello");12}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful