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

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

Source:SeleniumTestRunnerTest.java Github

copy

Full Screen

...34import com.consol.citrus.selenium.actions.GetStoredFileAction;35import com.consol.citrus.selenium.actions.HoverAction;36import com.consol.citrus.selenium.actions.JavaScriptAction;37import com.consol.citrus.selenium.actions.NavigateAction;38import com.consol.citrus.selenium.actions.OpenWindowAction;39import com.consol.citrus.selenium.actions.SetInputAction;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"));...

Full Screen

Full Screen

Source:SeleniumTestDesignerTest.java Github

copy

Full Screen

...24import com.consol.citrus.selenium.actions.GetStoredFileAction;25import com.consol.citrus.selenium.actions.HoverAction;26import com.consol.citrus.selenium.actions.JavaScriptAction;27import com.consol.citrus.selenium.actions.NavigateAction;28import com.consol.citrus.selenium.actions.OpenWindowAction;29import com.consol.citrus.selenium.actions.SetInputAction;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);...

Full Screen

Full Screen

Source:OpenWindowActionParser.java Github

copy

Full Screen

...15 */16package com.consol.citrus.selenium.config.xml;17import com.consol.citrus.config.util.BeanDefinitionParserUtils;18import com.consol.citrus.selenium.actions.AbstractSeleniumAction;19import com.consol.citrus.selenium.actions.OpenWindowAction;20import org.springframework.beans.factory.support.BeanDefinitionBuilder;21import org.springframework.beans.factory.xml.ParserContext;22import org.w3c.dom.Element;23/**24 * @author Tamer Erdogan, Christoph Deppisch25 * @since 2.726 */27public class OpenWindowActionParser extends AbstractBrowserActionParser {28 @Override29 protected void parseAction(BeanDefinitionBuilder beanDefinition, Element element, ParserContext parserContext) {30 BeanDefinitionParserUtils.setPropertyValue(beanDefinition, element.getAttribute("name"), "windowName");31 }32 @Override33 protected Class<? extends AbstractSeleniumAction> getBrowserActionClass() {34 return OpenWindowAction.class;35 }36}...

Full Screen

Full Screen

OpenWindowAction

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.OpenWindowAction;4import org.openqa.selenium.By;5import org.testng.annotations.Test;6public class OpenWindowActionJavaIT extends TestNGCitrusTestRunner {7 public void openWindowAction() {8 variable("windowName", "Consol");9 selenium().openWindow(new OpenWindowAction.Builder()10 .url("${url}")11 .windowName("${windowName}")12 .build());13 selenium().switchToWindow("${windowName}");14 selenium().element(By.linkText("News")).click();15 selenium().element(By.linkText("Consol Labs")).click();16 selenium().closeWindow();17 selenium().switchToWindow("default");18 }19}20import com.consol.citrus.annotations.CitrusTest;21import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;22import com.consol.citrus.selenium.actions.OpenWindowAction;23import org.openqa.selenium.By;24import org.testng.annotations.Test;25public class OpenWindowActionJavaIT extends TestNGCitrusTestRunner {26 public void openWindowAction() {27 variable("windowName", "Consol");28 selenium().openWindow(new OpenWindowAction.Builder()29 .url("${url}")30 .windowName("${windowName}")31 .build());32 selenium().switchToWindow("${windowName}");33 selenium().element(By.linkText("News")).click();34 selenium().element(By.linkText("Consol Labs")).click();35 selenium().closeWindow();36 selenium().switchToWindow("default");37 }38}39import com.consol.citrus.annotations.CitrusTest;40import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;41import com.consol.citrus.selenium.actions.OpenWindowAction;42import org.openqa.selenium.By;43import org.testng.annotations.Test;

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.selenium.actions.OpenWindowAction;2import com.consol.citrus.selenium.endpoint.SeleniumBrowser;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.testng.TestNGCitrusSupport;5import org.openqa.selenium.By;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.chrome.ChromeDriver;9import org.openqa.selenium.chrome.ChromeOptions;10import org.openqa.selenium.support.ui.ExpectedConditions;11import org.openqa.selenium.support.ui.WebDriverWait;12import org.springframework.beans.factory.annotation.Autowired;13import org.springframework.core.io.ClassPathResource;14import org.testng.annotations.Test;15import java.util.ArrayList;16import java.util.List;17import static org.testng.Assert.assertEquals;18public class 3 extends TestNGCitrusSupport {19 private SeleniumBrowser seleniumBrowser;20 private ChromeDriver chromeDriver;21 @CitrusParameters({"url"})22 public void testOpenWindowAction() {23 variable("searchQuery", "Citrus Framework");24 run(new OpenWindowAction()25 .browser(seleniumBrowser)26 .url("${url}"));27 run(new OpenWindowAction()28 .browser(seleniumBrowser)29 .url("${url}"));30 run(new OpenWindowAction()31 .browser(seleniumBrowser)32 .url("${url}"));33 List<String> windowHandles = new ArrayList<String>(chromeDriver.getWindowHandles());34 assertEquals(windowHandles.size(), 4);35 run(new OpenWindowAction()36 .browser(seleniumBrowser)37 .url("${url}"));38 windowHandles = new ArrayList<String>(chromeDriver.getWindowHandles());39 assertEquals(windowHandles.size(), 5);40 run(new OpenWindowAction()41 .browser(seleniumBrowser)42 .url("${url}"));43 windowHandles = new ArrayList<String>(chromeDriver.getWindowHandles());44 assertEquals(windowHandles.size(), 6);45 }46}

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.sample;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.selenium.actions.OpenWindowAction;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.beans.factory.annotation.Qualifier;6import org.testng.annotations.Test;7public class 3 extends TestNGCitrusTestDesigner {8 @Qualifier("selenium")9 private SeleniumBrowser browser;10 public void openWindowAction() {11 variable("windowName", "google");12 run(openWindowAction()13 .browser(browser)14 .url("${url}")15 .windowName("${windowName}"));16 }17}18package com.consol.citrus.sample;19import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;20import com.consol.citrus.selenium.actions.OpenWindowAction;21import org.springframework.beans.factory.annotation.Autowired;22import org.springframework.beans.factory.annotation.Qualifier;23import org.testng.annotations.Test;24public class 4 extends TestNGCitrusTestDesigner {25 @Qualifier("selenium")26 private SeleniumBrowser browser;27 public void openWindowAction() {28 variable("windowName", "google");29 run(openWindowAction()30 .browser(browser)31 .url("${url}")32 .windowName("${windowName}"));33 }34}35package com.consol.citrus.sample;36import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;37import com.consol.citrus.selenium.actions.OpenWindowAction;38import org.springframework.beans.factory.annotation.Autowired;39import org.springframework.beans.factory.annotation.Qualifier;40import org.testng.annotations.Test;41public class 5 extends TestNGCitrusTestDesigner {42 @Qualifier("selenium")43 private SeleniumBrowser browser;44 public void openWindowAction() {45 variable("windowName", "google");46 run(openWindowAction()47 .browser(browser)48 .url("${url}")

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.selenium.actions;2import com.consol.citrus.selenium.endpoint.SeleniumBrowser;3import com.consol.citrus.selenium.endpoint.SeleniumHeaders;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.support.ui.ExpectedConditions;7import org.openqa.selenium.support.ui.WebDriverWait;8import org.springframework.util.StringUtils;9public class OpenWindowAction extends AbstractSeleniumAction {10 private String windowHandle;11 public OpenWindowAction() {12 super("open-window");13 }14 public void doExecute(SeleniumBrowser browser) {15 WebDriver webDriver = browser.getWebDriver();16 windowHandle = webDriver.getWindowHandle();17 webDriver.switchTo().window(windowHandle);18 getEndpoint().createProducer().send(getMessage(browser), getEndpoint().getEndpointConfiguration().getTimeout());19 }20 protected void setHeaders(SeleniumBrowser browser, SeleniumHeaders headers) {21 super.setHeaders(browser, headers);22 if (StringUtils.hasText(windowHandle)) {23 headers.setWindowHandle(windowHandle);24 }25 }26 public String getWindowHandle() {27 return windowHandle;28 }29 public void setWindowHandle(String windowHandle) {30 this.windowHandle = windowHandle;31 }32}33package com.consol.citrus.selenium.actions;34import com.consol.citrus.selenium.endpoint.SeleniumBrowser;35import com.consol.citrus.selenium.endpoint.SeleniumHeaders;36import org.openqa.selenium.WebDriver;37import org.openqa.selenium.WebElement;38import org.openqa.selenium.support.ui.ExpectedConditions;39import org.openqa.selenium.support.ui.WebDriverWait;40import org.springframework.util.StringUtils;41public class OpenWindowAction extends AbstractSeleniumAction {42 private String windowHandle;43 public OpenWindowAction() {44 super("open-window");45 }

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1package org.citrusframework.demo;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.selenium.actions.OpenWindowAction;5import org.springframework.beans.factory.annotation.Autowired;6import org.springframework.core.io.ClassPathResource;7import org.springframework.core.io.Resource;8import org.springframework.http.HttpStatus;9import org.springframework.http.MediaType;10import org.springframework.web.client.RestTemplate;11import org.testng.annotations.Test;12import java.util.HashMap;13import java.util.Map;14public class 3 extends TestNGCitrusTestDesigner {15 private RestTemplate restTemplate;16 public void 3() {17 description("This test case is to test the OpenWindowAction class of com.consol.citrus.selenium.actions package");18 variable("title", "Google");19 variable("windowName", "google");20 variable("windowHandle", "google");21 echo("Open a new window");22 action(new OpenWindowAction()23 .url("{{url}}")24 .windowName("{{windowName}}")25 .windowHandle("{{windowHandle}}")26 .title("{{title}}")27 );28 }29}30package org.citrusframework.demo;31import com.consol.citrus.annotations.CitrusTest;32import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;33import com.consol.citrus.selenium.actions.PauseAction;34import org.springframework.beans.factory.annotation.Autowired;35import org.springframework.core.io.ClassPathResource;36import org.springframework.core.io.Resource;37import org.springframework.http.HttpStatus;38import org.springframework.http.MediaType;39import org.springframework.web.client.RestTemplate;40import org.testng.annotations.Test;41import java.util.HashMap;42import java.util.Map;43public class 4 extends TestNGCitrusTestDesigner {44 private RestTemplate restTemplate;45 public void 4() {46 description("This test case is to test the PauseAction class of com.consol.citrus.selenium.actions package");47 echo("Pause for 3 seconds");48 action(new PauseAction()49 .milliseconds(3000)50 );51 }52}

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1OpenWindowAction openWindowAction = new OpenWindowAction();2openWindowAction.setWebDriver(webDriver);3openWindowAction.setWindowName("testWindow");4openWindowAction.execute(context);5CloseWindowAction closeWindowAction = new CloseWindowAction();6closeWindowAction.setWebDriver(webDriver);7closeWindowAction.setWindowName("testWindow");8closeWindowAction.execute(context);9SetWindowSizeAction setWindowSizeAction = new SetWindowSizeAction();10setWindowSizeAction.setWebDriver(webDriver);11setWindowSizeAction.setSize("600, 800");12setWindowSizeAction.execute(context);13SetWindowPositionAction setWindowPositionAction = new SetWindowPositionAction();14setWindowPositionAction.setWebDriver(webDriver);15setWindowPositionAction.setPosition("100, 200");16setWindowPositionAction.execute(context);17SwitchToFrameAction switchToFrameAction = new SwitchToFrameAction();18switchToFrameAction.setWebDriver(webDriver);19switchToFrameAction.setFrame("testFrame");20switchToFrameAction.execute(context);21SwitchToDefaultFrameAction switchToDefaultFrameAction = new SwitchToDefaultFrameAction();22switchToDefaultFrameAction.setWebDriver(webDriver);23switchToDefaultFrameAction.execute(context);24SwitchToWindowAction switchToWindowAction = new SwitchToWindowAction();25switchToWindowAction.setWebDriver(webDriver);26switchToWindowAction.setWindow("testWindow");27switchToWindowAction.execute(context);28SwitchToDefaultWindowAction switchToDefaultWindowAction = new SwitchToDefaultWindowAction();29switchToDefaultWindowAction.setWebDriver(webDriver);30switchToDefaultWindowAction.execute(context);

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1public class 3 extends TestNGCitrusTestDesigner {2 public void 3() {3 variable("title", "Citrus: Selenium 2");4 variable("element", "id=firstName");5 variable("value", "John");6 open(new OpenWindowAction.Builder()7 .url("${url}")8 .windowName("seleniumWindow")9 .build());10 verifyTitle(new VerifyTitleAction.Builder()11 .title("${title}")12 .build());13 setFocus(new SetFocusAction.Builder()14 .element("${element}")15 .build());16 enterText(new EnterTextAction.Builder()17 .element("${element}")18 .text("${value}")19 .build());20 verifyText(new VerifyTextAction.Builder()21 .element("${element}")22 .text("${value}")23 .build());24 closeWindow(new CloseWindowAction.Builder()25 .windowName("seleniumWindow")26 .build());27 }28}29public class 4 extends TestNGCitrusTestDesigner {30 public void 4() {31 variable("title", "Citrus: Selenium 2");32 variable("element", "id=firstName");33 variable("value", "John");34 open(new OpenWindowAction.Builder()35 .url("${url}")36 .windowName("seleniumWindow")37 .build());38 verifyTitle(new VerifyTitleAction.Builder()39 .title("${title}")40 .build());41 setFocus(new SetFocusAction.Builder()42 .element("${element}")43 .build());44 enterText(new EnterTextAction.Builder()45 .element("${element}")46 .text("${value}")47 .build());48 verifyText(new VerifyTextAction.Builder()49 .element("${element}")50 .text("${value}")51 .build());52 closeWindow(new CloseWindowAction.Builder()53 .windowName("seleniumWindow")54 .build());55 }56}57public class 5 extends TestNGCitrusTestDesigner {

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1public class 3 extends AbstractTestNGCitrusTest {2 public void 3() {3 variable("title", "Home");4 variable("username", "admin");5 variable("password", "admin");6 variable("login", "Login");7 variable("logout", "Logout");8 variable("usernameField", "username");9 variable("passwordField", "password");10 variable("loginButton", "Login");11 variable("logoutButton", "Logout");12 variable("welcomeMessage", "Welcome to Citrus!");13 variable("searchField", "q");14 variable("searchButton", "btnG");15 variable("searchResult", "Citrus");16 variable("searchResultLink", "Citrus: Open source integration testing framework");17 variable("searchRe

Full Screen

Full Screen

OpenWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.selenium;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.chrome.ChromeOptions;5import org.springframework.context.annotation.Bean;6import org.springframework.context.annotation.Configuration;7import org.springframework.context.annotation.Scope;8import com.consol.citrus.selenium.actions.OpenWindowAction;9import com.consol.citrus.selenium.endpoint.SeleniumBrowser;10import com.consol.citrus.selenium.endpoint.SeleniumBrowserBuilder;11import com.consol.citrus.selenium.endpoint.SeleniumHeaders;12public class SeleniumConfig {13 @Scope("prototype")14 public SeleniumBrowser seleniumBrowser() {15 return new SeleniumBrowserBuilder()16 .browserType(SeleniumBrowserBuilder.BrowserType.CHROME)17 .build();18 }19 @Scope("prototype")20 public OpenWindowAction openWindowAction() {21 return new OpenWindowAction();22 }23 @Scope("prototype")24 public WebDriver webDriver() {25 ChromeOptions options = new ChromeOptions();26 options.addArguments("start-maximized");27 options.addArguments("disable-infobars");28 options.addArguments("--disable-extensions");29 options.addArguments("--disable-gpu");30 options.addArguments("--disable-dev-shm-usage");31 options.addArguments("--no-sandbox");32 return new ChromeDriver(options);33 }34 public SeleniumHeaders seleniumHeaders() {35 return new SeleniumHeaders();36 }37}38package com.consol.citrus.selenium;39import com.consol.citrus.annotations.CitrusTest;40import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;41import com.consol.citrus.selenium.actions.OpenWindowAction;42import org.springframework.beans.factory.annotation.Autowired;43import org.springframework.test.context.ContextConfiguration;44import org.testng.annotations.Test;45@ContextConfiguration(classes = {SeleniumConfig.class})

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.

Most used methods in OpenWindowAction

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