How to use page method of com.consol.citrus.cucumber.step.runner.selenium.SeleniumSteps class

Best Citrus code snippet using com.consol.citrus.cucumber.step.runner.selenium.SeleniumSteps.page

Source:SeleniumStepsTest.java Github

copy

Full Screen

1/*2 * Copyright 2006-2017 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.cucumber.step.runner.selenium;17import com.consol.citrus.Citrus;18import com.consol.citrus.annotations.CitrusAnnotations;19import com.consol.citrus.dsl.actions.DelegatingTestAction;20import com.consol.citrus.dsl.annotations.CitrusDslAnnotations;21import com.consol.citrus.dsl.runner.DefaultTestRunner;22import com.consol.citrus.dsl.runner.TestRunner;23import com.consol.citrus.selenium.actions.*;24import com.consol.citrus.selenium.endpoint.SeleniumBrowser;25import com.consol.citrus.selenium.endpoint.SeleniumBrowserConfiguration;26import com.consol.citrus.testng.AbstractTestNGUnitTest;27import cucumber.api.Scenario;28import org.mockito.Mockito;29import org.openqa.selenium.*;30import org.openqa.selenium.chrome.ChromeDriver;31import org.springframework.beans.factory.annotation.Autowired;32import org.testng.Assert;33import org.testng.annotations.*;34import java.net.URL;35import static org.mockito.ArgumentMatchers.any;36import static org.mockito.Mockito.verify;37import static org.mockito.Mockito.when;38/**39 * @author Christoph Deppisch40 * @since 2.741 */42public class SeleniumStepsTest extends AbstractTestNGUnitTest {43 private Citrus citrus;44 private SeleniumSteps steps;45 private TestRunner runner;46 @Autowired47 private SeleniumBrowser seleniumBrowser;48 private ChromeDriver webDriver = Mockito.mock(ChromeDriver.class);49 @BeforeClass50 public void setup() {51 citrus = Citrus.newInstance(applicationContext);52 }53 @BeforeMethod54 public void injectResources() {55 steps = new SeleniumSteps();56 runner = new DefaultTestRunner(applicationContext, context);57 CitrusAnnotations.injectAll(steps, citrus, context);58 CitrusDslAnnotations.injectTestRunner(steps, runner);59 }60 @Test61 public void testStart() {62 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();63 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");64 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);65 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);66 steps.setBrowser("seleniumBrowser");67 steps.start();68 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);69 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);70 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();71 Assert.assertEquals(action.getBrowser(), seleniumBrowser);72 Assert.assertTrue(action instanceof StartBrowserAction);73 verify(seleniumBrowser).start();74 }75 @Test76 public void testStop() {77 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();78 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");79 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);80 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);81 steps.setBrowser("seleniumBrowser");82 steps.stop();83 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);84 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);85 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();86 Assert.assertEquals(action.getBrowser(), seleniumBrowser);87 Assert.assertTrue(action instanceof StopBrowserAction);88 verify(seleniumBrowser).stop();89 }90 @Test91 public void testNavigate() {92 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();93 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");94 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);95 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);96 WebDriver.Navigation navigation = Mockito.mock(WebDriver.Navigation.class);97 when(webDriver.navigate()).thenReturn(navigation);98 steps.setBrowser("seleniumBrowser");99 steps.navigate("http://localhost:8080/test");100 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);101 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);102 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();103 Assert.assertEquals(action.getBrowser(), seleniumBrowser);104 Assert.assertTrue(action instanceof NavigateAction);105 Assert.assertEquals(((NavigateAction)action).getPage(), "http://localhost:8080/test");106 verify(navigation).to(any(URL.class));107 }108 @Test109 public void testClick() {110 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();111 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");112 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);113 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);114 WebElement element = Mockito.mock(WebElement.class);115 when(element.isDisplayed()).thenReturn(true);116 when(element.isEnabled()).thenReturn(true);117 when(element.getTagName()).thenReturn("button");118 when(webDriver.findElement(any(By.class))).thenAnswer(invocation -> {119 By select = (By) invocation.getArguments()[0];120 Assert.assertEquals(select.getClass(), By.ById.class);121 Assert.assertEquals(select.toString(), "By.id: foo");122 return element;123 });124 steps.setBrowser("seleniumBrowser");125 steps.click("id", "foo");126 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);127 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);128 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();129 Assert.assertEquals(action.getBrowser(), seleniumBrowser);130 Assert.assertTrue(action instanceof ClickAction);131 Assert.assertEquals(((ClickAction)action).getProperty(), "id");132 Assert.assertEquals(((ClickAction)action).getPropertyValue(), "foo");133 verify(element).click();134 }135 @Test136 public void testSetInput() {137 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();138 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");139 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);140 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);141 WebElement element = Mockito.mock(WebElement.class);142 when(element.isDisplayed()).thenReturn(true);143 when(element.isEnabled()).thenReturn(true);144 when(element.getTagName()).thenReturn("input");145 when(webDriver.findElement(any(By.class))).thenReturn(element);146 steps.setBrowser("seleniumBrowser");147 steps.setInput("Hello","id", "foo");148 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);149 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);150 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();151 Assert.assertEquals(action.getBrowser(), seleniumBrowser);152 Assert.assertTrue(action instanceof SetInputAction);153 Assert.assertEquals(((SetInputAction)action).getValue(), "Hello");154 Assert.assertEquals(((SetInputAction)action).getProperty(), "id");155 Assert.assertEquals(((SetInputAction)action).getPropertyValue(), "foo");156 verify(element).clear();157 verify(element).sendKeys("Hello");158 }159 @Test160 public void testCheckInput() {161 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();162 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");163 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);164 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);165 WebElement element = Mockito.mock(WebElement.class);166 when(element.isDisplayed()).thenReturn(true);167 when(element.isEnabled()).thenReturn(true);168 when(element.getTagName()).thenReturn("input");169 when(webDriver.findElement(any(By.class))).thenReturn(element);170 steps.setBrowser("seleniumBrowser");171 steps.checkInput("check","id", "foo");172 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);173 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);174 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();175 Assert.assertEquals(action.getBrowser(), seleniumBrowser);176 Assert.assertTrue(action instanceof CheckInputAction);177 Assert.assertEquals(((CheckInputAction)action).isChecked(), true);178 Assert.assertEquals(((CheckInputAction)action).getProperty(), "id");179 Assert.assertEquals(((CheckInputAction)action).getPropertyValue(), "foo");180 verify(element).click();181 }182 @Test183 public void testShouldDisplay() {184 SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration();185 when(seleniumBrowser.getName()).thenReturn("seleniumBrowser");186 when(seleniumBrowser.getWebDriver()).thenReturn(webDriver);187 when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration);188 WebElement element = Mockito.mock(WebElement.class);189 when(element.isDisplayed()).thenReturn(true);190 when(element.isEnabled()).thenReturn(true);191 when(element.getTagName()).thenReturn("button");192 when(webDriver.findElement(any(By.class))).thenAnswer(invocation -> {193 By select = (By) invocation.getArguments()[0];194 Assert.assertEquals(select.getClass(), By.ByName.class);195 Assert.assertEquals(select.toString(), "By.name: foo");196 return element;197 });198 steps.setBrowser("seleniumBrowser");199 steps.should_display("name", "foo");200 Assert.assertEquals(runner.getTestCase().getActionCount(), 1L);201 Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate() instanceof SeleniumAction);202 SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)).getDelegate();203 Assert.assertEquals(action.getBrowser(), seleniumBrowser);204 Assert.assertTrue(action instanceof FindElementAction);205 Assert.assertEquals(((FindElementAction)action).getProperty(), "name");206 Assert.assertEquals(((FindElementAction)action).getPropertyValue(), "foo");207 }208 209 @Test210 public void testDefaultBrowserInitialization() {211 Assert.assertNull(steps.browser);212 steps.before(Mockito.mock(Scenario.class));213 Assert.assertNotNull(steps.browser);214 }215 @Test216 public void testBrowserInitialization() {217 Assert.assertNull(steps.browser);218 steps.setBrowser("seleniumBrowser");219 steps.before(Mockito.mock(Scenario.class));220 Assert.assertNotNull(steps.browser);221 }222}...

Full Screen

Full Screen

Source:SeleniumSteps.java Github

copy

Full Screen

...39 protected TestRunner runner;40 @CitrusFramework41 protected Citrus citrus;42 /** Page objects defined by id */43 private Map<String, WebPage> pages;44 /** Page validators defined by id */45 private Map<String, PageValidator> validators;46 /** Selenium browser */47 protected SeleniumBrowser browser;48 @Before49 public void before(Scenario scenario) {50 if (browser == null && citrus.getApplicationContext().getBeansOfType(SeleniumBrowser.class).size() == 1L) {51 browser = citrus.getApplicationContext().getBean(SeleniumBrowser.class);52 }53 pages = new HashMap<>();54 validators = new HashMap<>();55 }56 @Given("^(?:selenium )?browser \"([^\"]+)\"$")57 public void setBrowser(String id) {58 if (!citrus.getApplicationContext().containsBean(id)) {59 throw new CitrusRuntimeException("Unable to find selenium browser for id: " + id);60 }61 browser = citrus.getApplicationContext().getBean(id, SeleniumBrowser.class);62 }63 @Given("^pages$")64 public void pages(DataTable dataTable) {65 Map<String, String> variables = dataTable.asMap(String.class, String.class);66 for (Map.Entry<String, String> entry : variables.entrySet()) {67 page(entry.getKey(), entry.getValue());68 }69 }70 @Given("^page \"([^\"]+)\" ([^\\s]+)$")71 public void page(String id, String type) {72 try {73 pages.put(id, (WebPage) Class.forName(type).newInstance());74 } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {75 throw new CitrusRuntimeException("Failed to laod page object", e);76 }77 }78 @Given("^page validators")79 public void page_validators(DataTable dataTable) {80 Map<String, String> variables = dataTable.asMap(String.class, String.class);81 for (Map.Entry<String, String> entry : variables.entrySet()) {82 page_validator(entry.getKey(), entry.getValue());83 }84 }85 @Given("^page validator ([^\\s]+) ([^\\s]+)$")86 public void page_validator(String id, String type) {87 try {88 validators.put(id, (PageValidator) Class.forName(type).newInstance());89 } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {90 throw new CitrusRuntimeException("Failed to laod page object", e);91 }92 }93 @When("^(?:user )?starts? browser$")94 public void start() {95 runner.selenium(action ->action.browser(browser)96 .start());97 }98 @When("^(?:user )?stops? browser$")99 public void stop() {100 runner.selenium(action ->action.browser(browser)101 .stop());102 }103 @When("^(?:user )?navigates? to \"([^\"]+)\"$")104 public void navigate(String url) {105 runner.selenium(action ->action.browser(browser)106 .navigate(url));107 }108 @When("^(?:user )?clicks? (?:element|button|link) with ([^\"]+)=\"([^\"]+)\"$")109 public void click(String property, String value) {110 runner.selenium(action ->action.browser(browser)111 .click()112 .element(property, value));113 }114 @When("^(?:user )?(?:sets?|puts?) text \"([^\"]+)\" to (?:element|input|textfield) with ([^\"]+)=\"([^\"]+)\"$")115 public void setInput(String text, String property, String value) {116 runner.selenium(action ->action.browser(browser)117 .setInput(text)118 .element(property, value));119 }120 @When("^(?:user )?(checks?|unchecks?) checkbox with ([^\"]+)=\"([^\"]+)\"$")121 public void checkInput(String type, String property, String value) {122 runner.selenium(action ->action.browser(browser)123 .checkInput(type.equals("check") || type.equals("checks"))124 .element(property, value));125 }126 @Then("^(?:page )?should (?:display|have) (?:element|button|link|input|textfield|form|heading) with (id|name|class-name|link-text|css-selector|tag-name|xpath)=\"([^\"]+)\"$")127 public void should_display(String property, String value) {128 runner.selenium(action ->action.browser(browser)129 .find()130 .enabled(true)131 .displayed(true)132 .element(property, value));133 }134 @Then("^(?:page )?should (?:display|have) (?:element|button|link|input|textfield|form|heading) with (id|name|class-name|link-text|css-selector|tag-name|xpath)=\"([^\"]+)\" having$")135 public void should_display(String property, String value, DataTable dataTable) {136 Map<String, String> elementProperties = dataTable.asMap(String.class, String.class);137 runner.selenium(action -> {138 SeleniumActionBuilder.FindElementActionBuilder elementBuilder = action.browser(browser)139 .find()140 .element(property, value);141 for (Map.Entry<String, String> propertyEntry : elementProperties.entrySet()) {142 if (propertyEntry.getKey().equals("tag-name")) {143 elementBuilder.tagName(propertyEntry.getValue());144 }145 if (propertyEntry.getKey().equals("text")) {146 elementBuilder.text(propertyEntry.getValue());147 }148 if (propertyEntry.getKey().equals("enabled")) {149 elementBuilder.enabled(Boolean.valueOf(propertyEntry.getValue()));150 }151 if (propertyEntry.getKey().equals("displayed")) {152 elementBuilder.displayed(Boolean.valueOf(propertyEntry.getValue()));153 }154 if (propertyEntry.getKey().equals("styles") || propertyEntry.getKey().equals("style")) {155 String[] propertyExpressions = StringUtils.delimitedListToStringArray(propertyEntry.getValue(), ";");156 for (String propertyExpression : propertyExpressions) {157 String[] keyValue = propertyExpression.split("=");158 elementBuilder.style(keyValue[0].trim(), VariableUtils.cutOffDoubleQuotes(keyValue[1].trim()));159 }160 }161 if (propertyEntry.getKey().equals("attributes") || propertyEntry.getKey().equals("attribute")) {162 String[] propertyExpressions = StringUtils.commaDelimitedListToStringArray(propertyEntry.getValue());163 for (String propertyExpression : propertyExpressions) {164 String[] keyValue = propertyExpression.split("=");165 elementBuilder.attribute(keyValue[0].trim(), VariableUtils.cutOffDoubleQuotes(keyValue[1].trim()));166 }167 }168 }169 });170 }171 @When("^(?:page )?([^\\s]+) performs ([^\\s]+)$")172 public void page_action(String pageId, String method) {173 page_action_with_arguments(pageId, method, null);174 }175 @When("^(?:page )?([^\\s]+) performs ([^\\s]+) with arguments$")176 public void page_action_with_arguments(String pageId, String method, DataTable dataTable) {177 verifyPage(pageId);178 runner.selenium(action -> {179 List<String> arguments = new ArrayList<>();180 if (dataTable != null) {181 arguments = dataTable.asList(String.class);182 }183 action.browser(browser)184 .page(pages.get(pageId))185 .execute(method)186 .arguments(arguments);187 });188 }189 @Then("^(?:page )?([^\\s]+) should validate$")190 public void page_should_validate(String pageId) {191 page_should_validate_with_validator(pageId, null);192 }193 @Then("^(?:page )?([^\\s]+) should validate with ([^\\s]+)$")194 public void page_should_validate_with_validator(String pageId, String validatorId) {195 verifyPage(pageId);196 runner.selenium(action -> {197 PageValidator pageValidator = null;198 if (validators.containsKey(validatorId)) {199 pageValidator = validators.get(validatorId);200 }201 action.browser(browser)202 .page(pages.get(pageId))203 .validator(pageValidator)204 .validate();205 });206 }207 /**208 * Verify that page is known.209 * @param pageId210 */211 private void verifyPage(String pageId) {212 if (!pages.containsKey(pageId)) {213 throw new CitrusRuntimeException(String.format("Unknown page '%s' - please introduce page with type information first", pageId));214 }215 }216}...

Full Screen

Full Screen

page

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.cucumber.step.runner.selenium;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.context.TestContext;4import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;5import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;6import com.consol.citrus.selenium.endpoint.SeleniumBrowser;7import com.consol.citrus.selenium.endpoint.SeleniumHeaders;8import com.consol.citrus.selenium.endpoint.SeleniumSettings;9import org.openqa.selenium.chrome.ChromeDriver;10import org.openqa.selenium.chrome.ChromeOptions;11import org.openqa.selenium.remote.DesiredCapabilities;12import org.springframework.beans.factory.annotation.Autowired;13import org.testng.annotations.Test;14public class SeleniumStepsIT extends TestNGCitrusTestRunner {15 private SeleniumSteps seleniumSteps;16 public void testSeleniumSteps() {17 seleniumSteps.setBrowser("chrome");18 seleniumSteps.setBrowser("chrome");19 seleniumSteps.setImplicitWait(5000);20 seleniumSteps.setBrowser("chrome");21 seleniumSteps.setImplicitWait(5000);22 seleniumSteps.setBrowser("chrome");23 seleniumSteps.setImplicitWait(5000);24 seleniumSteps.setPageLoadTimeout(5000);25 seleniumSteps.setScriptTimeout(5000);26 seleniumSteps.setBrowser("chrome");27 seleniumSteps.setImplicitWait(5000);28 seleniumSteps.setPageLoadTimeout(5000);29 seleniumSteps.setScriptTimeout(5000);30 seleniumSteps.setSeleniumSettings(new SeleniumSettings());31 seleniumSteps.setBrowser("chrome");32 seleniumSteps.setImplicitWait(5000);33 seleniumSteps.setPageLoadTimeout(5000);34 seleniumSteps.setScriptTimeout(500

Full Screen

Full Screen

page

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.cucumber.step.runner.selenium.SeleniumSteps;2import com.consol.citrus.cucumber.step.runner.core.CoreSteps;3import cucumber.api.java.en.Given;4import cucumber.api.java.en.Then;5import cucumber.api.java.en.When;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.chrome.ChromeOptions;9import java.util.HashMap;10import java.util.Map;11public class 3 {12 private WebDriver driver;13 private SeleniumSteps selenium;14 private CoreSteps core;15 @Given("^I open the browser$")16 public void iOpenTheBrowser() {17 Map<String, Object> prefs = new HashMap<String, Object>();18 prefs.put("profile.default_content_setting_values.notifications", 2);19 ChromeOptions options = new ChromeOptions();20 options.setExperimentalOption("prefs", prefs);21 options.setExperimentalOption("useAutomationExtension", false);22 System.setProperty("webdriver.chrome.driver", "C:\\Users\\User\\Downloads\\chromedriver_win32\\chromedriver.exe");23 driver = new ChromeDriver(options);24 selenium = new SeleniumSteps(driver);25 core = new CoreSteps();26 }27 @When("^I navigate to \"([^\"]*)\"$")28 public void iNavigateTo(String url) {29 selenium.page(url);30 }31 @Then("^I should see the title as \"([^\"]*)\"$")32 public void iShouldSeeTheTitleAs(String title) {33 core.validate("title", title);34 }35 @Then("^I close the browser$")36 public void iCloseTheBrowser() {37 driver.quit();38 }39}40import com.consol.citrus.cucumber.step.runner.selenium.SeleniumSteps;41import com.consol.citrus.cucumber.step.runner.core.CoreSteps;42import cucumber.api.java.en.Given;43import cucumber.api.java.en.Then;44import cucumber.api.java.en.When;45import org.openqa.selenium.WebDriver;46import org.openqa.selenium.chrome.ChromeDriver;47import org.openqa.selenium.chrome.ChromeOptions;48import java.util.HashMap;49import java.util.Map;50public class 4 {51 private WebDriver driver;52 private SeleniumSteps selenium;53 private CoreSteps core;54 @Given("^I open the browser$")55 public void iOpenTheBrowser() {56 Map<String, Object> prefs = new HashMap<String, Object>();

Full Screen

Full Screen

page

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.cucumber.step.runner.core.CitrusSteps;2import com.consol.citrus.cucumber.step.runner.selenium.SeleniumSteps;3import com.consol.citrus.cucumber.step.runner.selenium.page.Page;4import com.consol.citrus.cucumber.step.runner.selenium.page.PageElement;5import com.consol.citrus.cucumber.step.runner.selenium.page.PageElementLocator;6import org.openqa.selenium.By;7public class Page1 extends Page {8 public Page1(CitrusSteps citrusSteps) {9 super(citrusSteps);10 }11 public String name() {12 return "Page1";13 }14 public String url() {15 }16 public void init() {17 addElement("searchBox", new PageElement(this, new PageElementLocator(By.name("q"), "searchBox")));18 addElement("searchButton", new PageElement(this, new PageElementLocator(By.name("btnK"), "searchButton")));19 }20 public void search(String searchQuery) {21 ((SeleniumSteps) citrusSteps).page(this).element("searchBox").sendKeys(searchQuery);22 ((SeleniumSteps) citrusSteps).page(this).element("searchButton").click();23 }24}25import com.consol.citrus.annotations.CitrusTest;26import com.consol.citrus.cucumber.CitrusCucumberRunner;27import cucumber.api.CucumberOptions;28import cucumber.api.java.en.Then;29import cucumber.api.java.en.When;30import org.junit.runner.RunWith;31@RunWith(CitrusCucumberRunner.class)32@CucumberOptions(features = "classpath:com/consol/citrus/cucumber/features/3.feature")33public class 3 {34 @When("^I search \"(.*)\"$")35 public void search(String searchQuery) {36 new Page1(this).search(searchQuery);37 }38 @Then("^I should see \"(.*)\"$")39 public void shouldSee(String text) {40 ((SeleniumSteps) this).page("Page1").element("searchBox").shouldContain(text);41 }42}

Full Screen

Full Screen

page

Using AI Code Generation

copy

Full Screen

1public void page(String arg0) {2 SeleniumSteps seleniumSteps = new SeleniumSteps();3 seleniumSteps.page(arg0);4}5public void page(String arg0) {6 SeleniumSteps seleniumSteps = new SeleniumSteps();7 seleniumSteps.page(arg0);8}9public void page(String arg0) {10 SeleniumSteps seleniumSteps = new SeleniumSteps();11 seleniumSteps.page(arg0);12}13public void page(String arg0) {14 SeleniumSteps seleniumSteps = new SeleniumSteps();15 seleniumSteps.page(arg0);16}17public void page(String arg0) {18 SeleniumSteps seleniumSteps = new SeleniumSteps();19 seleniumSteps.page(arg0);20}21public void page(String arg0) {22 SeleniumSteps seleniumSteps = new SeleniumSteps();23 seleniumSteps.page(arg0);24}25public void page(String arg0) {26 SeleniumSteps seleniumSteps = new SeleniumSteps();27 seleniumSteps.page(arg0);28}29public void page(String arg0) {30 SeleniumSteps seleniumSteps = new SeleniumSteps();31 seleniumSteps.page(arg0);32}33public void page(String arg0) {34 SeleniumSteps seleniumSteps = new SeleniumSteps();35 seleniumSteps.page(arg0);36}

Full Screen

Full Screen

page

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.cucumber.step.runner.selenium.SeleniumSteps;2public class 3 extends SeleniumSteps {3 @Given("I open the browser")4 public void iOpenTheBrowser() {5 open().browser("chrome");6 }7 @Given("I go to the website {string}")8 public void iGoToTheWebsite(String url) {9 navigate().to(url);10 }11 @When("I enter {string} in the search box")12 public void iEnterInTheSearchBox(String search) {13 enter(search).into("search");14 }15 @When("I click on the search button")16 public void iClickOnTheSearchButton() {17 click().on("search-button");18 }19 @Then("I should see {string} in the results")20 public void iShouldSeeInTheResults(String text) {21 verify().text(text).exists();22 }23}

Full Screen

Full Screen

page

Using AI Code Generation

copy

Full Screen

1@Given("^I am on the \"([^\"]*)\" page$")2public void i_am_on_the_page(String page) throws Throwable {3 seleniumSteps.page(page);4}5@When("^I click on the \"([^\"]*)\" element$")6public void i_click_on_the_element(String element) throws Throwable {7 seleniumSteps.click(element);8}9@Then("^I verify that the \"([^\"]*)\" element is visible$")10public void i_verify_that_the_element_is_visible(String element) throws Throwable {11 seleniumSteps.verify(element);12}13@Then("^I verify that the \"([^\"]*)\" element is not visible$")14public void i_verify_that_the_element_is_not_visible(String element) throws Throwable {15 seleniumSteps.verify(element);16}17@Then("^I verify that the \"([^\"]*)\" element is not present$")18public void i_verify_that_the_element_is_not_present(String element) throws Throwable {19 seleniumSteps.verify(element);20}21@Then("^I verify that the \"([^\"]*)\" element is present$")22public void i_verify_that_the_element_is_present(String element) throws Throwable {23 seleniumSteps.verify(element);24}25@Then("^I verify that the \"([^\"]*)\" element is not enabled$")26public void i_verify_that_the_element_is_not_enabled(String element) throws Throwable {27 seleniumSteps.verify(element);28}29@Then("^I verify

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful