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

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

Source:SeleniumTestRunnerTest.java Github

copy

Full Screen

...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");...

Full Screen

Full Screen

Source:SeleniumTestDesignerTest.java Github

copy

Full Screen

...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());...

Full Screen

Full Screen

Source:SeleniumActionBuilder.java Github

copy

Full Screen

...9import com.consol.citrus.selenium.actions.DropDownSelectAction;10import com.consol.citrus.selenium.actions.FindElementAction;11import com.consol.citrus.selenium.actions.GetStoredFileAction;12import com.consol.citrus.selenium.actions.HoverAction;13import com.consol.citrus.selenium.actions.JavaScriptAction;14import com.consol.citrus.selenium.actions.MakeScreenshotAction;15import com.consol.citrus.selenium.actions.NavigateAction;16import com.consol.citrus.selenium.actions.OpenWindowAction;17import com.consol.citrus.selenium.actions.PageAction;18import com.consol.citrus.selenium.actions.SeleniumAction;19import com.consol.citrus.selenium.actions.SetInputAction;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 }113 public CloseWindowAction.Builder close() {114 return delegate.close();115 }116 public SwitchWindowAction.Builder focus() {117 return delegate.focus();118 }119 @Override120 public SeleniumAction build() {121 return delegate.build();...

Full Screen

Full Screen

JavaScriptAction

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 org.openqa.selenium.JavascriptExecutor;5public class JavaScriptAction extends AbstractSeleniumAction {6 private String script;7 public JavaScriptAction(Builder<?, ?> builder) {8 super("javascript", builder);9 this.script = builder.script;10 }11 public void doExecute(SeleniumBrowser browser, TestContext context) {12 JavascriptExecutor js = browser.getWebDriver();13 js.executeScript(script);14 }15 public String getScript() {16 return script;17 }18 public void setScript(String script) {19 this.script = script;20 }21 public static class Builder extends AbstractSeleniumAction.Builder<JavaScriptAction, Builder> {22 private String script;23 public Builder() {24 super(new JavaScriptAction());25 }26 public Builder script(String script) {27 action.script = script;28 return this;29 }30 public JavaScriptAction build() {31 return action;32 }33 }34}35package com.consol.citrus.selenium.actions;36import com.consol.citrus.context.TestContext;37import com.consol.citrus.selenium.endpoint.SeleniumBrowser;38import org.openqa.selenium.JavascriptExecutor;39public class JavaScriptAction extends AbstractSeleniumAction {40 private String script;41 public JavaScriptAction(Builder<?, ?> builder) {42 super("javascript", builder);43 this.script = builder.script;44 }45 public void doExecute(SeleniumBrowser browser, TestContext context) {46 JavascriptExecutor js = browser.getWebDriver();47 js.executeScript(script);48 }49 public String getScript() {50 return script;51 }52 public void setScript(String script) {53 this.script = script;54 }

Full Screen

Full Screen

JavaScriptAction

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 org.openqa.selenium.By;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.interactions.Actions;7import org.openqa.selenium.support.ui.ExpectedConditions;8import org.openqa.selenium.support.ui.WebDriverWait;9public class JavaScriptAction extends AbstractSeleniumAction {10 private final String script;11 private final String element;12 public JavaScriptAction(Builder builder) {13 super("javascript", builder);14 this.script = builder.script;15 this.element = builder.element;16 }17 public void doExecute(SeleniumBrowser browser, TestContext context) {18 if (script != null) {19 browser.executeJavaScript(context.replaceDynamicContentInString(script));20 } else if (element != null) {21 WebElement webElement = browser.getWebDriver().findElement(By.xpath(element));22 new Actions(browser.getWebDriver()).moveToElement(webElement).perform();23 }24 }25 public String getScript() {26 return script;27 }28 public String getElement() {29 return element;30 }31 public static class Builder extends AbstractSeleniumAction.Builder<JavaScriptAction, Builder> {32 private String script;33 private String element;34 public Builder() {35 super("javascript");36 }37 public Builder script(String script) {38 this.script = script;39 return this;40 }41 public Builder element(String element) {42 this.element = element;43 return this;44 }45 public JavaScriptAction build() {46 return new JavaScriptAction(this);47 }48 }49}50package com.consol.citrus.selenium.actions;51import com.consol.citrus.testng.AbstractTestNGUnitTest;52import org.openqa.selenium.By;53import org.openqa.selenium.WebElement;54import org.openqa.selenium.support.ui.ExpectedConditions;55import org.openqa.selenium.support.ui.WebDriverWait;56import org.testng.annotations.Test;57import java.util.ArrayList;58import java.util.List;59import static org.mockito.Mockito.*;60public class JavaScriptActionTest extends AbstractTestNGUnitTest {

Full Screen

Full Screen

JavaScriptAction

Using AI Code Generation

copy

Full Screen

1public class 3 extends AbstractTestNGCitrusTest {2 public void 3() {3 variable("search", "Citrus Framework");4 selenium().navigate("${url}");5 selenium().click(WebElementBuilder.link().name("Gmail"));6 selenium().click(WebElementBuilder.link().name("Sign in"));7 selenium().type(WebElementBuilder.input().id("Email"), "

Full Screen

Full Screen

JavaScriptAction

Using AI Code Generation

copy

Full Screen

1public class 3 extends TestNGCitrusTestDesigner {2 public void 3() {3 selenium().start();4 selenium().switchTo().window(0);5 selenium().type("name=q", "Citrus Framework");6 selenium().click("name=btnG");7 selenium().waitForPageToLoad(5000);8 selenium().verifyTextPresent("citrusframework.org");9 selenium().stop();10 }11}12public class 4 extends TestNGCitrusTestDesigner {13 public void 4() {14 selenium().start();15 selenium().switchTo().window(0);16 selenium().type("name=q", "Citrus Framework");17 selenium().click("name=btnG");18 selenium().waitForPageToLoad(5000);19 selenium().verifyTextPresent("citrusframework.org");20 selenium().javascript().execute("alert('Citrus Framework Rocks!')");21 selenium().stop();22 }23}

Full Screen

Full Screen

JavaScriptAction

Using AI Code Generation

copy

Full Screen

1public class 3 extends TestCase {2 public void 3() {3 selenium().click().element(By.name("q"));4 selenium().type().element(By.name("q")).text("Citrus");5 selenium().click().element(By.name("btnK"));6 selenium().executeJS("alert('Hello Citrus!')");7 }8}9public class 4 extends TestCase {10 public void 4() {11 selenium().click().element(By.name("q"));12 selenium().type().element(By.name("q")).text("Citrus");13 selenium().click().element(By.name("btnK"));14 selenium().executeJS("alert('Hello Citrus!')");15 selenium().executeJS("alert('Hello Citrus!')", "Citrus");16 }17}18public class 5 extends TestCase {19 public void 5() {20 selenium().click().element(By.name("q"));21 selenium().type().element(By.name("q")).text("Citrus");22 selenium().click().element(By.name("btnK"));23 selenium().executeJS("alert('Hello Citrus!')");24 selenium().executeJS("alert('Hello Citrus!')", "Citrus");25 selenium().executeJS("alert('Hello Citrus!')", "Citrus", "Selenium");26 }27}28public class 6 extends TestCase {29 public void 6() {30 selenium().click().element(By.name("q"));31 selenium().type().element(By.name("q")).text("Cit

Full Screen

Full Screen

JavaScriptAction

Using AI Code Generation

copy

Full Screen

1public class 3 extends AbstractTestNGCitrusTest {2 public void 3() {3 selenium().open()4 .browser(BrowserType.CHROME)5 .start(true);6 selenium().navigate()7 .to("${url}");8 selenium().javascript()9 .execute("document.getElementById('lst-ib').value='Citrus'");10 selenium().javascript()11 .execute("document.getElementsByName('btnK')[0].click()");12 selenium().javascript()13 .execute("document.getElementById('lst-ib').value='Citrus'");14 selenium().javascript()15 .execute("document.getElementsByName('btnK')[0].click()");16 selenium().javascript()17 .execute("document.getElementById('lst-ib').value='Citrus'");18 selenium().javascript()19 .execute("document.getElementsByName('btnK')[0].click()");20 selenium().javascript()21 .execute("document.getElementById('lst-ib').value='Citrus'");22 selenium().javascript()23 .execute("document.getElementsByName('btnK')[0].click()");24 selenium().javascript()25 .execute("document.getElementById('lst-ib').value='Citrus'");26 selenium().javascript()27 .execute("document.getElementsByName('btnK')[0].click()");28 selenium().javascript()29 .execute("document.getElementById('lst-ib').value='Citrus'");30 selenium().javascript()31 .execute("document.getElementsByName('btnK')[0].click()");32 selenium().javascript()33 .execute("document.getElementById('lst-ib').value='Citrus'");34 selenium().javascript()35 .execute("document.getElementsByName('btnK')[0].click()");36 selenium().javascript()37 .execute("document.getElementById('lst-ib').value='Citrus'");38 selenium().javascript()39 .execute("document.getElementsByName('btnK')[0].click()");40 selenium().javascript()41 .execute("document.getElementById('lst-ib').value='Citrus'");42 selenium().javascript()43 .execute("document.getElementsByName('btnK')[0].click()");44 selenium().javascript()45 .execute("document.getElementById('lst-ib').value='Citrus'");46 selenium().javascript()47 .execute("document.getElementsByName('btnK')[0].click()");48 selenium().javascript()49 .execute("document.getElementById('lst-ib').value='Citrus'");

Full Screen

Full Screen

JavaScriptAction

Using AI Code Generation

copy

Full Screen

1public class 3.java extends TestNGCitrusTestDesigner {2 public void javascriptAction() {3 selenium().javascriptAction()4 .script("alert('Hello World');");5 }6}7public class 4.java extends TestNGCitrusTestDesigner {8 public void javascriptAction() {9 selenium().javascriptAction()10 .script("alert('Hello World');");11 }12}13public class 5.java extends TestNGCitrusTestDesigner {14 public void javascriptAction() {15 selenium().javascriptAction()16 .script("alert('Hello World');");17 }18}19public class 6.java extends TestNGCitrusTestDesigner {20 public void javascriptAction() {21 selenium().javascriptAction()22 .script("alert('Hello World');");23 }24}25public class 7.java extends TestNGCitrusTestDesigner {26 public void javascriptAction() {27 selenium().javascriptAction()28 .script("alert('Hello World');");29 }30}31public class 8.java extends TestNGCitrusTestDesigner {32 public void javascriptAction() {

Full Screen

Full Screen

JavaScriptAction

Using AI Code Generation

copy

Full Screen

1public class MyTest extends TestNGCitrusTestDesigner {2 public void test() {3 selenium().javascriptAction("window.alert('Test');");4 }5}6public class MyTest extends TestNGCitrusTestDesigner {7 public void test() {8 selenium().javascriptAction("return document.title");9 }10}11public class MyTest extends TestNGCitrusTestDesigner {12 public void test() {13 selenium().javascriptAction("return document.title").execute();14 }15}16public class MyTest extends TestNGCitrusTestDesigner {17 public void test() {18 selenium().javascriptAction("return document.title").execute();19 }20}21public class MyTest extends TestNGCitrusTestDesigner {22 public void test() {23 selenium().javascriptAction("return document.title").execute();24 }25}26public class MyTest extends TestNGCitrusTestDesigner {27 public void test() {28 selenium().javascriptAction("return document.title").execute();29 }30}31public class MyTest extends TestNGCitrusTestDesigner {32 public void test() {33 selenium().javascriptAction("return document.title").execute();34 }35}36public class MyTest extends TestNGCitrusTestDesigner {37 public void test() {38 selenium().javascriptAction("return document.title").execute();39 }40}

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