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

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

Source:SeleniumTestRunnerTest.java Github

copy

Full Screen

...28import com.consol.citrus.selenium.actions.AlertAction;29import com.consol.citrus.selenium.actions.CheckInputAction;30import com.consol.citrus.selenium.actions.ClearBrowserCacheAction;31import com.consol.citrus.selenium.actions.ClickAction;32import com.consol.citrus.selenium.actions.CloseWindowAction;33import com.consol.citrus.selenium.actions.FindElementAction;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"));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");...

Full Screen

Full Screen

Source:SeleniumTestDesignerTest.java Github

copy

Full Screen

...18import com.consol.citrus.selenium.actions.AlertAction;19import com.consol.citrus.selenium.actions.CheckInputAction;20import com.consol.citrus.selenium.actions.ClearBrowserCacheAction;21import com.consol.citrus.selenium.actions.ClickAction;22import com.consol.citrus.selenium.actions.CloseWindowAction;23import com.consol.citrus.selenium.actions.FindElementAction;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);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 }...

Full Screen

Full Screen

Source:CloseWindowActionParser.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.CloseWindowAction;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 CloseWindowActionParser 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 CloseWindowAction.class;35 }36}...

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;2import com.consol.citrus.selenium.actions.CloseWindowAction;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.core.io.ClassPathResource;8import org.testng.annotations.Test;9public class 3 extends TestNGCitrusTestDesigner {

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.selenium.actions.CloseWindowAction;2import com.consol.citrus.testng.CitrusParameters;3import com.consol.citrus.annotations.CitrusTest;4import com.consol.citrus.testng.AbstractTestNGCitrusTest;5import org.springframework.beans.factory.annotation.Autowired;6import org.springframework.http.HttpStatus;7import org.springframework.http.MediaType;8import org.springframework.http.ResponseEntity;9import org.springframework.http.client.ClientHttpResponse;10import org.springframework.web.client.ResponseErrorHandler;11import org.springframework.web.client.RestTemplate;12import org.testng.annotations.Test;13import java.io.IOException;14import java.util.HashMap;15import java.util.Map;16import static com.consol.citrus.actions.EchoAction.Builder.echo;17import static com.consol.citrus.selenium.actions.SeleniumActionBuilder.selenium;18import static com.consol.citrus.selenium.actions.NavigateAction.Builder.navigate;19import static com.consol.citrus.selenium.actions.ClickAction.Builder.click;20import static com.consol.citrus.selenium.actions.SendKeysAction.Builder.sendKeys;21import static com.consol.citrus.selenium.actions.CloseWindowAction.Builder.closeWindow;22import static com.consol.citrus.selenium.actions.FindAction.Builder.find;23import static com.consol.citrus.selenium.actions.SwitchWindowAction.Builder.switchWindow;24import static com.consol.citrus.selenium.actions.SwitchToFrameAction.Builder.switchToFrame;25import static com.consol.citrus.selenium.actions.SwitchToParentFrameAction.Builder.switchToParentFrame;26import static com.consol.citrus.selenium.actions.SwitchToDefaultContentAction.Builder.switchToDefaultContent;27import static com.consol.citrus.selenium.actions.GetPageSourceAction.Builder.getPageSource;28import static com.consol.citrus.selenium.actions.GetTitleAction.Builder.getTitle;29import static com.consol.citrus.selenium.actions.GetUrlAction.Builder.getUrl;30import static com.consol.citrus.selenium.actions.RefreshAction.Builder.refresh;31import static com.consol.citrus.selenium.actions.GetElementTextAction.Builder.getElementText;32import static com.consol.citrus.selenium.actions.GetElementAttributeAction.Builder.getElementAttribute;33import static com.consol.citrus.selenium.actions.GetElementCssValueAction.Builder.getElementCssValue;34import static com.consol.citrus.selenium.actions.IsElementSelectedAction.Builder.isElementSelected;35import static com.consol.citrus.selenium.actions.IsElementDisplayedAction.Builder.isElementDisplayed;36import static com.consol.citrus.selenium.actions.IsElementEnabledAction.Builder.isElementEnabled;37import static com.con

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.testng;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.selenium.actions.CloseWindowAction;4import org.testng.annotations.Test;5public class CloseWindowActionJavaITest extends TestNGCitrusTestDesigner {6 public void closeWindowActionJavaITest() {7 selenium().closeWindow();8 }9}10package com.consol.citrus.dsl.testng;11import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;12import com.consol.citrus.selenium.actions.ClickAction;13import org.testng.annotations.Test;14public class ClickActionJavaITest extends TestNGCitrusTestDesigner {15 public void clickActionJavaITest() {16 selenium().click();17 }18}19package com.consol.citrus.dsl.testng;20import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;21import com.consol.citrus.selenium.actions.DragAndDropAction;22import org.testng.annotations.Test;23public class DragAndDropActionJavaITest extends TestNGCitrusTestDesigner {24 public void dragAndDropActionJavaITest() {25 selenium().dragAndDrop();26 }27}28package com.consol.citrus.dsl.testng;29import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;30import com.consol.citrus.selenium.actions.DragAndDropToOffsetAction;31import org.testng.annotations.Test;32public class DragAndDropToOffsetActionJavaITest extends TestNGCitrusTestDesigner {33 public void dragAndDropToOffsetActionJavaITest() {34 selenium().dragAndDropToOffset();35 }36}37package com.consol.citrus.dsl.testng;38import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;39import com.consol.citrus.selenium.actions.ExecuteScriptAction;40import org.testng.annotations.Test;

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.selenium.actions.CloseWindowAction;2import com.consol.citrus.selenium.actions.OpenAction;3import com.consol.citrus.selenium.actions.SwitchToWindowAction;4import com.consol.citrus.selenium.endpoint.SeleniumBrowser;5import com.consol.citrus.testng.spring.TestNGCitrusSpringSupport;6import org.openqa.selenium.WebDriver;7import org.springframework.beans.factory.annotation.Autowired;8import org.springframework.beans.factory.annotation.Qualifier;9import org.springframework.test.context.ContextConfiguration;10import org.testng.annotations.Test;11@ContextConfiguration(classes = { CitrusSpringConfig.class })12public class 3 extends TestNGCitrusSpringSupport {13 @Qualifier("seleniumBrowser")14 private SeleniumBrowser seleniumBrowser;15 public void 3() {16 selenium(action -> action17 .browser(seleniumBrowser)18 .start());19 selenium(action -> action20 .browser(seleniumBrowser)21 .open(new OpenAction.Builder()22 .url("${url}")23 .build()));24 selenium(action -> action25 .browser(seleniumBrowser)26 .switchToWindow(new SwitchToWindowAction.Builder()27 .windowName("Google")28 .build()));29 selenium(action -> action30 .browser(seleniumBrowser)31 .closeWindow(new CloseWindowAction.Builder()32 .windowName("Google")33 .build()));34 selenium(action -> action35 .browser(seleniumBrowser)36 .stop());37 }38}

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.annotations.CitrusTest;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.selenium.actions.CloseWindowAction;4import org.testng.annotations.Test;5public class CloseWindowActionDemo extends TestNGCitrusTestDesigner {6 public void closeWindowActionDemo() {7 variable("windowName", "Consol");8 variable("windowTitle", "Consol - The Citrus Company");9 selenium().navigate("${url}");10 selenium().newWindow().windowName("${windowName}").windowTitle("${windowTitle}");11 selenium().closeWindow().windowName("${windowName}");12 }13}14CloseWindowAction()15CloseWindowAction(Builder builder)16CloseWindowAction(String windowName)17CloseWindowAction(String windowName, String windowTitle)18CloseWindowAction(String windowName, String windowTitle, String windowHandle)19CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url)20CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource)21CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize)22CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition)23CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition, String screenshot)24CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition, String screenshot, String cookies)25CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition, String screenshot, String cookies, String pageSourceCode)26CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String window

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class CloseWindowActionIT extends TestNGCitrusTestDesigner {5 protected void configure() {6 selenium().closeWindow();7 }8}9package com.consol.citrus;10import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;11import org.testng.annotations.Test;12public class CloseWindowActionIT extends TestNGCitrusTestDesigner {13 protected void configure() {14 selenium().closeWindow("windowName");15 }16}17package com.consol.citrus;18import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;19import org.testng.annotations.Test;20public class CloseWindowActionIT extends TestNGCitrusTestDesigner {21 protected void configure() {22 variable("

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.testng;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class CloseWindowActionJavaIT extends TestNGCitrusTestDesigner {5 public void closeWindowActionJavaIT() {6 selenium().closeWindow();7 }8}9package com.consol.citrus.dsl.testng;10import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;11import org.testng.annotations.Test;12public class DoubleClickActionJavaIT extends TestNGCitrusTestDesigner {13 public void doubleClickActionJavaIT() {14 selenium().doubleClick("name=q");15 }16}17package com.consol.citrus.dsl.testng;18import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;19import org.testng.annotations.Test;20public class DragAndDropActionJavaIT extends TestNGCitrusTestDesigner {21 public void dragAndDropActionJavaIT() {22 selenium().dragAndDrop("name=q", "name=btnK");23 }24}25package com.consol.citrus.dsl.testng;26import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;27import org.testng.annotations.Test;28public class FocusActionJavaIT extends TestNGCitrusTestDesigner {29 public void focusActionJavaIT() {30 selenium().focus("name=q");31 }32}33package com.consol.citrus.dsl.testng;34import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;35import org.testng.annotations.Test;36public class HoverActionJavaIT extends TestNGCitrusTestDesigner {

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.testng;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.selenium.actions.CloseWindowAction;4import org.testng.annotations.Test;5public class CloseWindowActionJavaITest extends TestNGCitrusTestDesigner {6public void closeWindowActionJavaITest() {

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.selenium;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.testng.TestNGCitrusSupport;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.chrome.ChromeOptions;8import org.springframework.beans.factory.annotation.Autowired;9import org.springframework.beans.factory.annotation.Qualifier;10import org.testng.annotations.Test;11import java.util.HashMap;12import java.util.Map;13public class Selenium3JavaIT extends TestNGCitrusSupport {14 @Qualifier("selenium3")15 private SeleniumBrowser browser;16 @CitrusParameters({"url"})17 public void selenium3Test() {18 Map<String, Object> prefs = new HashMap<String, Object>();19 prefs.put("profile.default_content_setting_values.notifications", 2);20 ChromeOptions options = new ChromeOptions();21 options.setExperimentalOption("prefs", prefs);22 options.addArguments("--disable-extensions");23 options.addArguments("--disable-infobars");24 options.addArguments("--disable-notifications");25 options.addArguments("--disable-popup-blocking");26 options.addArguments("--disable-save-password-bubble");27 options.addArguments("--disable-translate");28 options.addArguments("--start-maximized");29 options.addArguments("--test-type");30 options.addArguments("--ignore-certificate-errors");31 options.addArguments("--allow-insecure-localhost");32 options.addArguments("--allow-running-insecure-content");33 WebDriver driver = new ChromeDriver(options);34 browser.setWebDriver(driver);35 echo("Open Google page");36 open(url = "${url}");37 echo("Search for Citrus");38 type(element = "q", text = "Citrus");39 submit(element = "q");40 echo("Verify Citrus search result");41 verifyText(element = "h3", text = "Citrus Framework");42 echo("Close browser");43 close();44 }45}46package com.consol.citrus.selenium;47import com.consol.citrus.annotations.CitrusTest;48import com.consol.citrus.testng.CitrusParameters;49import com.consol

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1public class CloseWindowActionDemo {2 public static void main(String[] args) {3 SeleniumActionBuilder builder = new SeleniumActionBuilder();4 builder.closeWindow();5 }6}7closeWindow() method of CloseWindowAction class closes the currently focused browser window. This method is used

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1public class CloseWindowActionDemo {2 public static void main(String[] args) {3 SeleniumActionBuilder builder = new SeleniumActionBuilder();4 builder.closeWindow();5 }6}7closeWindow() method of CloseWindowAction class closes the currently focused browser window. This method is used(String windowName)8CloseWindowAction(String windowName, String windowTitle)9CloseWindowAction(String windowName, String windowTitle, String windowHandle)10CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url)11CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource)12CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize)13CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition)14CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition, String screenshot)15CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition, String screenshot, String cookies)16CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String windowSize, String windowPosition, String screenshot, String cookies, String pageSourceCode)17CloseWindowAction(String windowName, String windowTitle, String windowHandle, String url, String pageSource, String window

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.testng;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import com.consol.citrus.selenium.actions.CloseWindowAction;4import org.testng.annotations.Test;5public class CloseWindowActionJavaITest extends TestNGCitrusTestDesigner {6public void closeWindowActionJavaITest() {

Full Screen

Full Screen

CloseWindowAction

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.selenium;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.testng.TestNGCitrusSupport;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.chrome.ChromeOptions;8import org.springframework.beans.factory.annotation.Autowired;9import org.springframework.beans.factory.annotation.Qualifier;10import org.testng.annotations.Test;11import java.util.HashMap;12import java.util.Map;13public class Selenium3JavaIT extends TestNGCitrusSupport {14 @Qualifier("selenium3")15 private SeleniumBrowser browser;16 @CitrusParameters({"url"})17 public void selenium3Test() {18 Map<String, Object> prefs = new HashMap<String, Object>();19 prefs.put("profile.default_content_setting_values.notifications", 2);20 ChromeOptions options = new ChromeOptions();21 options.setExperimentalOption("prefs", prefs);22 options.addArguments("--disable-extensions");23 options.addArguments("--disable-infobars");24 options.addArguments("--disable-notifications");25 options.addArguments("--disable-popup-blocking");26 options.addArguments("--disable-save-password-bubble");27 options.addArguments("--disable-translate");28 options.addArguments("--start-maximized");29 options.addArguments("--test-type");30 options.addArguments("--ignore-certificate-errors");31 options.addArguments("--allow-insecure-localhost");32 options.addArguments("--allow-running-insecure-content");33 WebDriver driver = new ChromeDriver(options);34 browser.setWebDriver(driver);35 echo("Open Google page");36 open(url = "${url}");37 echo("Search for Citrus");38 type(element = "q", text = "Citrus");39 submit(element = "q");40 echo("Verify Citrus search result");41 verifyText(element = "h3", text = "Citrus Framework");42 echo("Close browser");43 close();44 }45}46package com.consol.citrus.selenium;47import com.consol.citrus.annotations.CitrusTest;48import com.consol.citrus.testng.CitrusParameters;49import com.consol

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 CloseWindowAction

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