How to use ElementActionBuilder method of com.consol.citrus.dsl.builder.SeleniumActionBuilder class

Best Citrus code snippet using com.consol.citrus.dsl.builder.SeleniumActionBuilder.ElementActionBuilder

Source:SeleniumActionBuilder.java Github

copy

Full Screen

...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);572 this.action = action;573 }574 /**575 * Add tag name validation.576 * @param tagName577 * @return578 */579 public FindElementActionBuilder tagName(String tagName) {580 action.setTagName(tagName);581 return this;582 }583 /**584 * Add text validation.585 * @param text586 * @return587 */588 public FindElementActionBuilder text(String text) {589 action.setText(text);590 return this;591 }592 /**593 * Add attribute validation.594 * @param name595 * @param value596 * @return597 */598 public FindElementActionBuilder attribute(String name, String value) {599 action.getAttributes().put(name, value);600 return this;601 }602 /**603 * Add css style validation.604 * @param name605 * @param value606 * @return607 */608 public FindElementActionBuilder style(String name, String value) {609 action.getStyles().put(name, value);610 return this;611 }612 /**613 * Add enabled validation.614 * @param enabled615 * @return616 */617 public FindElementActionBuilder enabled(boolean enabled) {618 action.setEnabled(enabled);619 return this;620 }621 /**622 * Add displayed validation.623 * @param displayed624 * @return625 */626 public FindElementActionBuilder displayed(boolean displayed) {627 action.setDisplayed(displayed);628 return this;629 }630 @Override631 public FindElementActionBuilder element(By by) {632 super.element(by);633 return this;634 }635 @Override636 public FindElementActionBuilder element(String property, String propertyValue) {637 super.element(property, propertyValue);638 return this;639 }640 }641}...

Full Screen

Full Screen

ElementActionBuilder

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.runner.TestRunner;2import com.consol.citrus.selenium.endpoint.SeleniumBrowser;3public class ClickElement {4 public static void main(String[] args) {5 TestRunner runner = new TestRunner();6 SeleniumBrowser browser = runner.selenium().browser();7 runner.selenium()8 .actions()9 .element(browser.findElement("a", "class", "navbar-brand"))10 .click();11 }12}13import com.consol.citrus.dsl.runner.TestRunner;14import com.consol.citrus.selenium.endpoint.SeleniumBrowser;15import org.openqa.selenium.By;16public class ClickElement {17 public static void main(String[] args) {18 TestRunner runner = new TestRunner();19 SeleniumBrowser browser = runner.selenium().browser();20 runner.selenium()21 .actions()22 .element(By.className("navbar-brand"))23 .click();24 }25}26import com.consol.citrus.dsl.runner.TestRunner;27import com.consol.citrus.selenium.endpoint.SeleniumBrowser;28import org.openqa.selenium.By;29public class ClickElement {30 public static void main(String[] args) {31 TestRunner runner = new TestRunner();32 SeleniumBrowser browser = runner.selenium().browser();33 runner.selenium()34 .actions()35 .element(By.className("navbar-brand"))36 .click();37 }38}

Full Screen

Full Screen

ElementActionBuilder

Using AI Code Generation

copy

Full Screen

1public void testElementActionBuilder() {2 selenium().actions()3 .elementActionBuilder()4 .type("username", "citrus")5 .click("loginButton")6 .build();7}8public void testElementActionBuilder() {9 selenium().actions()10 .elementActionBuilder()11 .type("username", "citrus")12 .click("loginButton")13 .build();14}15public void testElementActionBuilder() {16 selenium().actions()17 .elementActionBuilder()18 .type("username", "citrus")19 .click("loginButton")20 .build();21}22public void testElementActionBuilder() {23 selenium().actions()24 .elementActionBuilder()25 .type("username", "citrus")26 .click("loginButton")27 .build();28}29public void testElementActionBuilder() {30 selenium().actions()31 .elementActionBuilder()32 .type("username", "citrus")33 .click("loginButton")34 .build();35}36public void testElementActionBuilder() {37 selenium().actions()38 .elementActionBuilder()39 .type("username", "citrus")40 .click("loginButton")41 .build();42}43public void testElementActionBuilder() {44 selenium().actions()45 .elementActionBuilder()46 .type("username", "citrus")47 .click("loginButton")48 .build();49}50public void testElementActionBuilder() {51 selenium().actions()52 .elementActionBuilder()53 .type("username", "citrus")54 .click("loginButton")55 .build();56}

Full Screen

Full Screen

ElementActionBuilder

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.builder.ElementActionBuilder;2SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();3seleniumActionBuilder.element()4.click()5import com.consol.citrus.dsl.builder.ElementActionBuilder;6SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();7seleniumActionBuilder.element()8.click()9import com.consol.citrus.dsl.builder.ElementActionBuilder;10SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();11seleniumActionBuilder.element()12.click()13import com.consol.citrus.dsl.builder.ElementActionBuilder;14SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();15seleniumActionBuilder.element()16.click()17SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();18seleniumActionBuilder.element()19.click()20SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();21seleniumActionBuilder.element()22.click()23SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();24seleniumActionBuilder.element()25.click()26SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();27seleniumActionBuilder.element()28.click()29SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();

Full Screen

Full Screen

ElementActionBuilder

Using AI Code Generation

copy

Full Screen

1SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();2seleniumActionBuilder.click()3.element(SeleniumActionBuilder.element()4.type("id")5.name("email")6.description("email input field"));7SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();8seleniumActionBuilder.click()9.element(SeleniumActionBuilder.element()10.type("id")11.name("email")12.description("email input field"));13SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();14seleniumActionBuilder.click()15.element(SeleniumActionBuilder.element()16.type("id")17.name("email")18.description("email input field"));19SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();20seleniumActionBuilder.click()21.element(SeleniumActionBuilder.element()22.type("id")23.name("email")24.description("email input field"));25SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();26seleniumActionBuilder.click()27.element(SeleniumActionBuilder.element()28.type("id")29.name("email")30.description("email input field"));31SeleniumActionBuilder seleniumActionBuilder = new SeleniumActionBuilder();32seleniumActionBuilder.click()33.element(SeleniumActionBuilder.element()34.type("id")35.name("

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful