Best Citrus code snippet using com.consol.citrus.dsl.builder.SeleniumActionBuilder.SeleniumActionBuilder
Source:SeleniumActionBuilder.java
...33 * 34 * @author Christoph Deppisch35 * @since 2.736 */37public class SeleniumActionBuilder extends AbstractTestActionBuilder<DelegatingTestAction<SeleniumAction>> {38 /** Selenium browser */39 private SeleniumBrowser seleniumBrowser;40 /**41 * Constructor using action field.42 * @param action43 */44 public SeleniumActionBuilder(DelegatingTestAction<SeleniumAction> action) {45 super(action);46 }47 /**48 * Default constructor.49 */50 public SeleniumActionBuilder() {51 super(new DelegatingTestAction<>());52 }53 /**54 * Use a custom selenium browser.55 */56 public SeleniumActionBuilder browser(SeleniumBrowser seleniumBrowser) {57 this.seleniumBrowser = seleniumBrowser;58 return this;59 }60 /**61 * Start browser instance.62 */63 public SeleniumActionBuilder start() {64 action(new StartBrowserAction());65 return this;66 }67 /**68 * Start explicit browser instance.69 */70 public SeleniumActionBuilder start(SeleniumBrowser seleniumBrowser) {71 browser(seleniumBrowser);72 action(new StartBrowserAction());73 return this;74 }75 /**76 * Stop browser instance.77 */78 public SeleniumActionBuilder stop() {79 action(new StopBrowserAction());80 return this;81 }82 /**83 * Stop explicit browser instance.84 */85 public SeleniumActionBuilder stop(SeleniumBrowser seleniumBrowser) {86 browser(seleniumBrowser);87 action(new StopBrowserAction());88 return this;89 }90 /**91 * Alert element.92 */93 public AlertActionBuilder alert() {94 AlertAction action = new AlertAction();95 action(action);96 return new AlertActionBuilder(action);97 }98 /**99 * Navigate action.100 */101 public SeleniumActionBuilder navigate(String page) {102 NavigateAction action = new NavigateAction();103 action.setPage(page);104 action(action);105 return this;106 }107 /**108 * Page action.109 */110 public PageActionBuilder page(WebPage page) {111 PageAction action = new PageAction();112 action.setPage(page);113 action(action);114 return new PageActionBuilder(action);115 }116 /**117 * Page action.118 */119 public PageActionBuilder page(Class<? extends WebPage> pageType) {120 PageAction action = new PageAction();121 action.setType(pageType.getName());122 action(action);123 return new PageActionBuilder(action);124 }125 /**126 * Finds element.127 */128 public FindElementActionBuilder find() {129 FindElementAction action = new FindElementAction();130 action(action);131 return new FindElementActionBuilder(action);132 }133 /**134 * Dropdown select single option action.135 */136 public ElementActionBuilder select(String option) {137 DropDownSelectAction action = new DropDownSelectAction();138 action.setOption(option);139 action(action);140 return new ElementActionBuilder(action);141 }142 /**143 * Dropdown select multiple options action.144 */145 public ElementActionBuilder select(String ... options) {146 DropDownSelectAction action = new DropDownSelectAction();147 action.setOptions(Arrays.asList(options));148 action(action);149 return new ElementActionBuilder(action);150 }151 /**152 * Set input action.153 */154 public ElementActionBuilder setInput(String value) {155 SetInputAction action = new SetInputAction();156 action.setValue(value);157 action(action);158 return new ElementActionBuilder(action);159 }160 /**161 * Check input action.162 */163 public ElementActionBuilder checkInput(boolean checked) {164 CheckInputAction action = new CheckInputAction();165 action.setChecked(checked);166 action(action);167 return new ElementActionBuilder(action);168 }169 /**170 * Clicks element.171 */172 public ElementActionBuilder click() {173 ClickAction action = new ClickAction();174 action(action);175 return new ElementActionBuilder(action);176 }177 /**178 * Hover element.179 */180 public ElementActionBuilder hover() {181 HoverAction action = new HoverAction();182 action(action);183 return new ElementActionBuilder(action);184 }185 /**186 * Clear browser cache.187 */188 public SeleniumActionBuilder clearCache() {189 action(new ClearBrowserCacheAction());190 return this;191 }192 /**193 * Make screenshot.194 */195 public SeleniumActionBuilder screenshot() {196 action(new MakeScreenshotAction());197 return this;198 }199 /**200 * Make screenshot with custom output directory.201 */202 public SeleniumActionBuilder screenshot(String outputDir) {203 MakeScreenshotAction action = new MakeScreenshotAction();204 action.setOutputDir(outputDir);205 action(action);206 return this;207 }208 /**209 * Store file.210 * @param filePath211 */212 public SeleniumActionBuilder store(String filePath) {213 StoreFileAction action = new StoreFileAction();214 action.setFilePath(filePath);215 action(action);216 return this;217 }218 /**219 * Get stored file.220 * @param fileName221 */222 public SeleniumActionBuilder getStored(String fileName) {223 GetStoredFileAction action = new GetStoredFileAction();224 action.setFileName(fileName);225 action(action);226 return this;227 }228 /**229 * Wait until element meets condition.230 */231 public WaitUntilActionBuilder waitUntil() {232 WaitUntilAction action = new WaitUntilAction();233 action(action);234 return new WaitUntilActionBuilder(action);235 }236 /**237 * Execute JavaScript.238 */239 public JavaScriptActionBuilder javascript(String script) {240 JavaScriptAction action = new JavaScriptAction();241 action.setScript(script);242 action(action);243 return new JavaScriptActionBuilder(action);244 }245 /**246 * Execute JavaScript.247 */248 public JavaScriptActionBuilder javascript(Resource script) {249 return javascript(script, FileUtils.getDefaultCharset());250 }251 /**252 * Execute JavaScript.253 */254 public JavaScriptActionBuilder javascript(Resource script, Charset charset) {255 JavaScriptAction action = new JavaScriptAction();256 try {257 action.setScript(FileUtils.readToString(script, charset));258 } catch (IOException e) {259 throw new CitrusRuntimeException("Failed to read script resource", e);260 }261 action(action);262 return new JavaScriptActionBuilder(action);263 }264 /**265 * Open window.266 */267 public WindowActionBuilder open() {268 OpenWindowAction action = new OpenWindowAction();269 action(action);270 return new WindowActionBuilder(action);271 }272 /**273 * Close window.274 */275 public WindowActionBuilder close() {276 CloseWindowAction action = new CloseWindowAction();277 action(action);278 return new WindowActionBuilder(action);279 }280 /**281 * Switch window.282 */283 public WindowActionBuilder focus() {284 SwitchWindowAction action = new SwitchWindowAction();285 action(action);286 return new WindowActionBuilder(action);287 }288 /**289 * Prepare selenium action.290 */291 private <T extends SeleniumAction> T action(T delegate) {292 if (seleniumBrowser != null) {293 delegate.setBrowser(seleniumBrowser);294 }295 action.setDelegate(delegate);296 return delegate;297 }298 /**299 * Customize alert action.300 */301 public class AlertActionBuilder implements TestActionBuilder {302 /** Alert action */303 private final AlertAction action;304 /**305 * Default constructor.306 * @param action307 */308 public AlertActionBuilder(AlertAction action) {309 this.action = action;310 }311 /**312 * Add alert text validation.313 * @param text314 * @return315 */316 public AlertActionBuilder text(String text) {317 action.setText(text);318 return this;319 }320 /**321 * Accept alert dialog.322 * @return323 */324 public AlertActionBuilder accept() {325 action.setAccept(true);326 return this;327 }328 /**329 * Dismiss alert dialog.330 * @return331 */332 public AlertActionBuilder dismiss() {333 action.setAccept(false);334 return this;335 }336 @Override337 public TestAction build() {338 return SeleniumActionBuilder.this.build();339 }340 }341 /**342 * Customize page action.343 */344 public class PageActionBuilder implements TestActionBuilder {345 /** Alert action */346 private final PageAction action;347 /**348 * Default constructor.349 * @param action350 */351 public PageActionBuilder(PageAction action) {352 this.action = action;353 }354 /**355 * Perform page validation.356 * @return357 */358 public PageActionBuilder validate() {359 action.setAction("validate");360 return this;361 }362 /**363 * Set page validator.364 * @param validator365 * @return366 */367 public PageActionBuilder validator(PageValidator validator) {368 action.setValidator(validator);369 return this;370 }371 /**372 * Set page action method to execute.373 * @param method374 * @return375 */376 public PageActionBuilder execute(String method) {377 action.setAction(method);378 return this;379 }380 /**381 * Set page action argument.382 * @param arg383 * @return384 */385 public PageActionBuilder argument(String arg) {386 action.getArguments().add(arg);387 return this;388 }389 /**390 * Set page action arguments.391 * @param args392 * @return393 */394 public PageActionBuilder arguments(String ... args) {395 action.setArguments(Arrays.asList(args));396 return this;397 }398 /**399 * Set page action arguments.400 * @param args401 * @return402 */403 public PageActionBuilder arguments(List<String> args) {404 action.setArguments(args);405 return this;406 }407 @Override408 public TestAction build() {409 return SeleniumActionBuilder.this.build();410 }411 }412 /**413 * Customize javascript action.414 */415 public class JavaScriptActionBuilder implements TestActionBuilder {416 /** JavaScript action */417 private final JavaScriptAction action;418 /**419 * Default constructor.420 * @param action421 */422 public JavaScriptActionBuilder(JavaScriptAction action) {423 this.action = action;424 }425 /**426 * Add script argument.427 * @param arg428 * @return429 */430 public JavaScriptActionBuilder argument(Object arg) {431 action.getArguments().add(arg);432 return this;433 }434 /**435 * Add expected error.436 * @param errors437 * @return438 */439 public JavaScriptActionBuilder errors(String ... errors) {440 action.setExpectedErrors(Arrays.asList(errors));441 return this;442 }443 @Override444 public TestAction build() {445 return SeleniumActionBuilder.this.build();446 }447 }448 /**449 * Customize wait until action.450 */451 public class WaitUntilActionBuilder extends ElementActionBuilder<WaitUntilAction> {452 /** WaitUntil action */453 private final WaitUntilAction action;454 /**455 * Default constructor.456 * @param action457 */458 public WaitUntilActionBuilder(WaitUntilAction action) {459 super(action);460 this.action = action;461 }462 /**463 * Add visible condition.464 * @return465 */466 public WaitUntilActionBuilder visible() {467 action.setCondition("visible");468 return this;469 }470 /**471 * Add hidden condition.472 * @return473 */474 public WaitUntilActionBuilder hidden() {475 action.setCondition("hidden");476 return this;477 }478 /**479 * Add timeout condition.480 * @return481 */482 public WaitUntilActionBuilder timeout(Long timeout) {483 action.setTimeout(timeout);484 return this;485 }486 @Override487 public WaitUntilActionBuilder element(By by) {488 super.element(by);489 return this;490 }491 @Override492 public WaitUntilActionBuilder element(String property, String propertyValue) {493 super.element(property, propertyValue);494 return this;495 }496 }497 /**498 * Window accessing action.499 */500 public class WindowActionBuilder implements TestActionBuilder {501 /** Window action */502 private final SeleniumWindowAction action;503 /**504 * Default constructor.505 * @param action506 */507 public WindowActionBuilder(SeleniumWindowAction action) {508 this.action = action;509 }510 /**511 * Set window name.512 * @param name513 * @return514 */515 public WindowActionBuilder window(String name) {516 action.setWindowName(name);517 return this;518 }519 @Override520 public TestAction build() {521 return SeleniumActionBuilder.this.build();522 }523 }524 /**525 * Customize element selecting action.526 */527 public class ElementActionBuilder<T extends FindElementAction> implements TestActionBuilder {528 /** Element action */529 private final T action;530 /**531 * Default constructor.532 * @param action533 */534 public ElementActionBuilder(T action) {535 this.action = action;536 }537 /**538 * Add element selector.539 * @param by540 * @return541 */542 public ElementActionBuilder element(By by) {543 action.setBy(by);544 return this;545 }546 /**547 * Add element property and value selector.548 * @return549 */550 public ElementActionBuilder element(String property, String propertyValue) {551 action.setProperty(property);552 action.setPropertyValue(propertyValue);553 return this;554 }555 @Override556 public TestAction build() {557 return SeleniumActionBuilder.this.build();558 }559 }560 /**561 * Customize element selecting action.562 */563 public class FindElementActionBuilder extends ElementActionBuilder<FindElementAction> {564 /** Find element action */565 private final FindElementAction action;566 /**567 * Default constructor.568 * @param action569 */570 public FindElementActionBuilder(FindElementAction action) {571 super(action);...
Source:TodoPagesIT.java
1/*2 * Copyright 2006-2016 the original author or authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.samples.todolist;17import com.consol.citrus.annotations.CitrusTest;18import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;19import com.consol.citrus.http.client.HttpClient;20import com.consol.citrus.samples.todolist.page.TodoPage;21import com.consol.citrus.samples.todolist.page.WelcomePage;22import com.consol.citrus.selenium.endpoint.SeleniumBrowser;23import org.openqa.selenium.By;24import org.springframework.beans.factory.annotation.Autowired;25import org.springframework.http.HttpStatus;26import org.testng.annotations.Test;27/**28 * @author Christoph Deppisch29 */30public class TodoPagesIT extends TestNGCitrusTestRunner {31 @Autowired32 private SeleniumBrowser browser;33 @Autowired34 private HttpClient todoClient;35 @Test36 @CitrusTest37 public void testIndexPage() {38 selenium(seleniumActionBuilder -> seleniumActionBuilder39 .browser(browser)40 .start());41 selenium(seleniumActionBuilder -> seleniumActionBuilder42 .navigate(todoClient.getEndpointConfiguration().getRequestUrl()));43 http(httpActionBuilder -> httpActionBuilder44 .client(todoClient)45 .send()46 .delete("/api/todolist"));47 http(httpActionBuilder -> httpActionBuilder48 .client(todoClient)49 .receive()50 .response(HttpStatus.OK));51 WelcomePage welcomePage = new WelcomePage();52 selenium(seleniumActionBuilder -> seleniumActionBuilder53 .page(welcomePage)54 .validate());55 selenium(seleniumActionBuilder -> seleniumActionBuilder56 .page(welcomePage)57 .execute("startApp"));58 selenium(seleniumActionBuilder -> seleniumActionBuilder59 .page(new TodoPage())60 .validate());61 }62 @Test63 @CitrusTest64 public void testAddEntry() {65 variable("todoName", "todo_citrus:randomNumber(4)");66 variable("todoDescription", "Description: ${todoName}");67 http(httpActionBuilder -> httpActionBuilder68 .client(todoClient)69 .send()70 .delete("/api/todolist"));71 http(httpActionBuilder -> httpActionBuilder72 .client(todoClient)73 .receive()74 .response(HttpStatus.OK));75 selenium(seleniumActionBuilder -> seleniumActionBuilder76 .browser(browser)77 .start());78 selenium(seleniumActionBuilder -> seleniumActionBuilder79 .navigate(todoClient.getEndpointConfiguration().getRequestUrl() + "/todolist"));80 TodoPage todoPage = new TodoPage();81 selenium(seleniumActionBuilder -> seleniumActionBuilder82 .page(todoPage)83 .validate());84 selenium(seleniumActionBuilder -> seleniumActionBuilder85 .page(todoPage)86 .argument("${todoName}")87 .argument("${todoDescription}")88 .execute("submit"));89 selenium(seleniumActionBuilder -> seleniumActionBuilder90 .waitUntil()91 .element(By.xpath("(//li[@class='list-group-item']/span)[last()]"))92 .timeout(2000L)93 .visible());94 selenium(seleniumActionBuilder -> seleniumActionBuilder95 .find()96 .element(By.xpath("(//li[@class='list-group-item']/span)[last()]"))97 .text("${todoName}"));98 }99}...
Source:TodoListIT.java
1/*2 * Copyright 2006-2016 the original author or authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.samples.todolist;17import com.consol.citrus.annotations.CitrusTest;18import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;19import com.consol.citrus.http.client.HttpClient;20import com.consol.citrus.selenium.endpoint.SeleniumBrowser;21import org.openqa.selenium.By;22import org.springframework.beans.factory.annotation.Autowired;23import org.springframework.http.HttpStatus;24import org.testng.annotations.Test;25/**26 * @author Christoph Deppisch27 */28public class TodoListIT extends TestNGCitrusTestRunner {29 @Autowired30 private SeleniumBrowser browser;31 @Autowired32 private HttpClient todoClient;33 @Test34 @CitrusTest35 public void testIndexPage() {36 selenium(seleniumActionBuilder -> seleniumActionBuilder37 .browser(browser)38 .start());39 selenium(seleniumActionBuilder -> seleniumActionBuilder40 .navigate(todoClient.getEndpointConfiguration().getRequestUrl()));41 selenium(seleniumActionBuilder -> seleniumActionBuilder42 .find()43 .enabled(true)44 .displayed(true)45 .element(By.linkText("Run application")));46 selenium(seleniumActionBuilder -> seleniumActionBuilder47 .click()48 .element(By.linkText("Run application")));49 selenium(seleniumActionBuilder -> seleniumActionBuilder50 .find()51 .element(By.tagName("h1"))52 .text("TODO list"));53 }54 @Test55 @CitrusTest56 public void testAddEntry() {57 variable("todoName", "todo_citrus:randomNumber(4)");58 variable("todoDescription", "Description: ${todoName}");59 http(httpActionBuilder -> httpActionBuilder60 .client(todoClient)61 .send()62 .delete("/api/todolist"));63 http(httpActionBuilder -> httpActionBuilder64 .client(todoClient)65 .receive()66 .response(HttpStatus.OK));67 selenium(seleniumActionBuilder -> seleniumActionBuilder68 .browser(browser)69 .start());70 selenium(seleniumActionBuilder -> seleniumActionBuilder71 .navigate(todoClient.getEndpointConfiguration().getRequestUrl() + "/todolist"));72 selenium(seleniumActionBuilder -> seleniumActionBuilder73 .find()74 .element(By.xpath("(//li[@class='list-group-item'])[last()]"))75 .text("No todos found"));76 selenium(seleniumActionBuilder -> seleniumActionBuilder77 .setInput("${todoName}")78 .element(By.name("title")));79 selenium(seleniumActionBuilder -> seleniumActionBuilder80 .setInput("${todoDescription}")81 .element(By.name("description"))82 );83 selenium(seleniumActionBuilder -> seleniumActionBuilder84 .click()85 .element(By.tagName("button")));86 selenium(seleniumActionBuilder -> seleniumActionBuilder87 .waitUntil()88 .element(By.xpath("(//li[@class='list-group-item']/span)[last()]"))89 .timeout(2000L)90 .visible());91 selenium(seleniumActionBuilder -> seleniumActionBuilder92 .find()93 .element(By.xpath("(//li[@class='list-group-item']/span)[last()]"))94 .text("${todoName}"));95 }96}...
SeleniumActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.actions.AbstractTestAction;3import com.consol.citrus.context.TestContext;4import com.consol.citrus.dsl.runner.TestRunner;5import com.consol.citrus.selenium.actions.SeleniumAction;6import com.consol.citrus.selenium.endpoint.SeleniumBrowser;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.interactions.Actions;10public class SeleniumActionBuilder extends AbstractTestActionBuilder<SeleniumAction, SeleniumActionBuilder> {11 private final SeleniumBrowser browser;12 private final WebDriver webDriver;13 private final TestRunner runner;14 private final Actions actions;15 public SeleniumActionBuilder(SeleniumBrowser browser, TestRunner runner) {16 super(new SeleniumAction());17 this.browser = browser;18 this.webDriver = browser.getWebDriver();19 this.runner = runner;20 this.actions = new Actions(webDriver);21 }22 public void doExecute(TestContext context) {23 action.setActions(actions);24 action.setBrowser(browser);25 action.execute(context);26 }27 public SeleniumActionBuilder actions(Actions actions) {28 action.setActions(actions);29 return this;30 }31 public SeleniumActionBuilder browser(SeleniumBrowser browser) {32 action.setBrowser(browser);33 return this;34 }35 public SeleniumActionBuilder webDriver(WebDriver webDriver) {36 action.setWebDriver(webDriver);37 return this;38 }39 public SeleniumActionBuilder runner(TestRunner runner) {40 action.setRunner(runner);41 return this;42 }43 public SeleniumActionBuilder click(WebElement element) {44 actions.click(element);45 return this;46 }47 public SeleniumActionBuilder doubleClick(WebElement element) {48 actions.doubleClick(element);49 return this;50 }
SeleniumActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.actions.AbstractTestAction;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.selenium.endpoint.SeleniumBrowser;5import org.openqa.selenium.By;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.WebElement;8import java.util.ArrayList;9import java.util.List;10public class SeleniumActionBuilder extends AbstractTestActionBuilder<SeleniumActionBuilder> {11 private final SeleniumBrowser browser;12 public SeleniumActionBuilder(TestRunner runner, SeleniumBrowser browser) {13 super(runner);14 this.browser = browser;15 }16 public SeleniumActionBuilder executeScript(String javaScript) {17 action = new ExecuteScriptAction(browser, javaScript);18 return this;19 }20 public SeleniumActionBuilder executeScript(String javaScript, Object ... arguments) {21 action = new ExecuteScriptAction(browser, javaScript, arguments);22 return this;23 }24 public SeleniumActionBuilder newWindow() {25 action = new NewWindowAction(browser);26 return this;27 }28 public SeleniumActionBuilder closeWindow() {29 action = new CloseWindowAction(browser);30 return this;31 }32 public SeleniumActionBuilder switchWindow(String windowName) {33 action = new SwitchWindowAction(browser, windowName);34 return this;35 }36 public SeleniumActionBuilder switchWindow(int windowHandle) {37 action = new SwitchWindowAction(browser,
SeleniumActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.actions.DelegatingTestAction;3import com.consol.citrus.dsl.actions.DelegatingTestAction.Builder;4import com.consol.citrus.dsl.actions.DelegatingTestAction.Builder.DelegatingTestActionBuilder;5import com.consol.citrus.selenium.actions.ClickAction;6import com.consol.citrus.selenium.actions.NavigateAction;7import com.consol.citrus.selenium.actions.SendKeysAction;8import com.consol.citrus.selenium.actions.SeleniumAction;9import com.consol.citrus.selenium.actions.SwitchToFrameAction;10import com.consol.citrus.selenium.actions.SwitchToWindowAction;11import org.openqa.selenium.By;12import org.openqa.selenium.WebDriver;13import org.openqa.selenium.WebElement;14import org.openqa.selenium.support.ui.Select;15public class SeleniumActionBuilder {16 private final Builder builder;17 public SeleniumActionBuilder() {18 builder = new Builder();19 }20 public SeleniumActionBuilder(WebDriver driver) {21 builder = new Builder(driver);22 }23 public SeleniumActionBuilder(WebElement webElement) {24 builder = new Builder(webElement);25 }26 public SeleniumActionBuilder(Select select) {27 builder = new Builder(select);28 }29 public SeleniumActionBuilder(By by) {30 builder = new Builder(by);31 }32 public SeleniumActionBuilder(String locator) {33 builder = new Builder(locator);34 }35 public SeleniumActionBuilder action(SeleniumAction action) {36 builder.action(action);37 return this;38 }39 public SeleniumActionBuilder action(DelegatingTestAction action) {40 builder.action(action);41 return this;42 }43 public SeleniumActionBuilder action(Builder action) {44 builder.action(action);45 return this;46 }47 public SeleniumActionBuilder action(DelegatingTestActionBuilder action) {48 builder.action(action);49 return this;50 }51 public DelegatingTestActionBuilder getBuilder() {
SeleniumActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.selenium.actions.ClearAction;3import com.consol.citrus.selenium.actions.ClickAction;4import com.consol.citrus.selenium.actions.ClickLinkAction;5import com.consol.citrus.selenium.actions.NavigateAction;6import com.consol.citrus.selenium.actions.SendKeysAction;7import com.consol.citrus.selenium.actions.SelectAction;8import com.consol.citrus.selenium.actions.VerifyAction;9import com.consol.citrus.selenium.endpoint.SeleniumBrowser;10import org.openqa.selenium.By;11import org.openqa.selenium.WebElement;12import org.openqa.selenium.support.ui.Select;13import java.util.List;14public class SeleniumActionBuilder {15 private SeleniumBrowser browser;16 public SeleniumActionBuilder(SeleniumBrowser browser) {17 this.browser = browser;18 }19 public NavigateAction navigate(String url) {20 NavigateAction action = new NavigateAction();21 action.setBrowser(browser);22 action.setUrl(url);23 return action;24 }25 public ClickAction click(String locator) {26 ClickAction action = new ClickAction();27 action.setBrowser(browser);28 action.setLocator(locator);29 return action;30 }31 public ClickAction click(By locator) {32 ClickAction action = new ClickAction();33 action.setBrowser(browser);34 action.setLocator(locator);35 return action;36 }37 public ClickAction click(WebElement element) {38 ClickAction action = new ClickAction();39 action.setBrowser(browser);40 action.setElement(element);41 return action;42 }43 public ClickLinkAction clickLink(String locator) {44 ClickLinkAction action = new ClickLinkAction();45 action.setBrowser(browser);46 action.setLocator(locator);47 return action;48 }49 public ClickLinkAction clickLink(By locator) {50 ClickLinkAction action = new ClickLinkAction();51 action.setBrowser(browser);52 action.setLocator(locator);53 return action;54 }55 public ClickLinkAction clickLink(WebElement element) {56 ClickLinkAction action = new ClickLinkAction();57 action.setBrowser(browser);58 action.setElement(element);59 return action;60 }61 public ClearAction clear(String locator) {62 ClearAction action = new ClearAction();63 action.setBrowser(browser);64 action.setLocator(locator);65 return action;66 }67 public ClearAction clear(By locator) {68 ClearAction action = new ClearAction();69 action.setBrowser(browser);
SeleniumActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.actions.selenium.*;3import com.consol.citrus.selenium.endpoint.SeleniumBrowser;4import com.consol.citrus.selenium.model.SeleniumPage;5import com.consol.citrus.selenium.model.SeleniumPageModel;6import com.consol.citrus.selenium.model.SeleniumPageModelBuilder;7import com.consol.citrus.selenium.model.SeleniumPageModelRegistry;8import com.consol.citrus.selenium.model.action.*;9import com.consol.citrus.selenium.model.action.ClickAction;10import com.consol.citrus.selenium.model.action.NavigateAction;11import com.consol.citrus.selenium.model.action.OpenAction;12import com.consol.citrus.selenium.model.action.SendKeysAction;13import com.consol.citrus.selenium.model.element.*;14import com.consol.citrus.selenium.model.element.ButtonElement;15import com.consol.citrus.selenium.model.element.InputElement;16import com.consol.citrus.selenium.model.element.LinkElement;17import com.consol.citrus.selenium.model.element.SelectElement;18import com.consol.citrus.selenium.model.locator.*;19import com.consol.citrus.selenium.model.locator.ClassNameLocator;20import com.consol.citrus.selenium.model.locator.CssSelectorLocator;21import com.consol.citrus.selenium.model.locator.IdLocator;22import com.consol.citrus.selenium.model.locator.LinkTextLocator;23import com.consol.citrus.selenium.model.locator.NameLocator;24import com.consol.citrus.selenium.model.locator.PartialLinkTextLocator;25import com.consol.citrus.selenium.model.locator.TagNameLocator;26import com.consol.citrus.selenium.model.locator.XPathLocator;27import com.consol.citrus.selenium.model.page.*;28import com.consol.citrus.selenium.model.page.LoginPage;29import com.consol.citrus.selen
SeleniumActionBuilder
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.selenium.action.*;3import java.util.*;4import org.springframework.util.StringUtils;5import com.consol.citrus.context.TestContext;6import com.consol.citrus.dsl.builder.AbstractTestContainerBuilder;7import com.consol.citrus.dsl.builder.AbstractTestContainerBuilder.TestActionContainerBuilder;8import com.consol.citrus.selenium.endpoint.SeleniumBrowser;9import com.consol.citrus.selenium.endpoint.SeleniumHeaders;10import com.consol.citrus.selenium.model.*;11import com.consol.citrus.selenium.model.SeleniumElementLocator;12import com.consol.citrus.selenium.model.SeleniumPage;13import com.consol.citrus.selenium.model.SeleniumPageModel;14import com.consol.citrus.selenium.model.SeleniumPageModelStore;15import com.consol.citrus.selenium.model.SeleniumPageModelStoreBuilder;16import com.consol.citrus.selenium.model.SeleniumPage
SeleniumActionBuilder
Using AI Code Generation
1public class 3.java extends AbstractTestNGCitrusTest {2 public void 3() {3 variable("myVar", "value");4 selenium().actions()5 .click("link=Download")6 .verifyText("id=download", "Download Citrus")7 .verifyTextPresent("Download Citrus")8 .verifyTextNotPresent("Download Citrus")9 .verifyTextPresent("css=div#download")10 .verifyText("css=div#download", "Download Citrus")11 .verifyTextPresent("css=div#download", "Download Citrus")12 .verifyTextNotPresent("css=div#download", "Download Citrus")13 .verifyTextPresent("link=Download Citrus")14 .verifyText("link=Download Citrus", "Download Citrus")15 .verifyTextPresent("link=Download Citrus", "Download Citrus")16 .verifyTextNotPresent("link=Download Citrus", "Download Citrus")17 .verifyTextPresent("name=download")18 .verifyText("name=download", "Download Citrus")19 .verifyTextPresent("name=download", "Download Citrus")20 .verifyTextNotPresent("name=download", "Download Citrus")21 .verifyTextPresent("id=download")22 .verifyText("id=download", "Download Citrus")23 .verifyTextPresent("id=download", "Download Citrus")24 .verifyTextNotPresent("id=download", "Download Citrus")25 .verifyTextPresent("class=download")26 .verifyText("class=download", "Download Citrus")27 .verifyTextPresent("class=download", "Download Citrus")28 .verifyTextNotPresent("class=download", "Download Citrus")29 .verifyTextPresent("tag=div")30 .verifyText("tag=div", "Download Citrus")31 .verifyTextPresent("tag=div", "Download Citrus
SeleniumActionBuilder
Using AI Code Generation
1import com.consol.citrus.dsl.builder.SeleniumActionBuilder;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import org.openqa.selenium.By;4import org.testng.annotations.Test;5public class SeleniumActions extends TestNGCitrusTestRunner {6 public void seleniumActions() {7 selenium()8 .browser(BrowserType.CHROME)9 .start();10 selenium()11 .navigate("${url}");12 selenium()13 .mouseOver(By.id("gb_70"));14 selenium()15 .stop();16 }17}18import com.consol.citrus.dsl.builder.SeleniumActionBuilder;19import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;20import org.openqa.selenium.By;21import org.testng.annotations.Test;22public class SeleniumActions extends TestNGCitrusTestRunner {23 public void seleniumActions() {24 selenium()25 .browser(BrowserType.CHROME)26 .start();27 selenium()28 .navigate("${url}");29 selenium()30 .mouseOver(By.id("gb_70"));31 selenium()32 .stop();33 }34}35import com.consol.citrus.dsl.builder.SeleniumActionBuilder;36import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;37import org.openqa.selenium.By;38import org.testng.annotations.Test;39public class SeleniumActions extends TestNGCitrusTestRunner {40 public void seleniumActions() {41 selenium()42 .browser(BrowserType.CHROME)43 .start();44 selenium()45 .navigate("${url}");46 selenium()47 .mouseOver(By.id("gb_70"));48 selenium()49 .stop();50 }51}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!