Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality. Learn more →
selenium-cucumber Open-Source Projects
-
NodeJs-Cucumber-Selenium
Run test automation on cloud with Cucumber.js and LambdaTest. This is a sample repo to help you execute Cucumber.js framework based test scripts in parallel with LambdaTest automation testing cloud
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
import org.openqa.selenium.By; import org.junit.jupiter.api.*; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.net.MalformedURLException; import java.net.URL; import java.util.List; import java.util.concurrent.TimeUnit; public class RunningTestsInParallelInGrid { String username = "YOUR_USERNAME"; //Enter your username String accesskey = "YOUR_ACCESS_KEY"; //Enter your accesskey static RemoteWebDriver driver = null; String gridURL = "@ hub.lambdatest.com/wd/hub"; String urlToTest = "https://www.lambdatest.com/"; @ BeforeAll public static void start() { System.out.println("=======Running junit 5 tests in parallel in LambdaTest Grid has started========"); } @ BeforeEach public void setup() { System.out.println("Setting up the drivers and browsers"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("browserName", "chrome"); //To specify the browser capabilities.setCapability("version", "70.0"); //To specify the browser version capabilities.setCapability("platform", "win10"); // To specify the OS capabilities.setCapability("build", "Running_ParallelJunit5Tests_In_Grid"); //To identify the test capabilities.setCapability("name", "Parallel_JUnit5Tests"); capabilities.setCapability("network", true); // To enable network logs capabilities.setCapability("visual", true); // To enable step by step screenshot capabilities.setCapability("video", true); // To enable video recording capabilities.setCapability("console", true); // To capture console logs try { driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities); } catch (MalformedURLException e) { System.out.println("Invalid grid URL"); } catch (Exception e) { System.out.println(e.getMessage()); } } @ Test @ DisplayName("Title_Test") @ Tag("Sanity") public void launchAndVerifyTitle_Test() { String methodName = Thread.currentThread() .getStackTrace()[1] .getMethodName(); System.out.println("********Execution of "+methodName+" has been started********"); System.out.println("Launching LambdaTest website started.."); driver.get(urlToTest); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); String actualTitle = driver.getTitle(); System.out.println("The page title is "+actualTitle); String expectedTitle ="Most Powerful Cross Browser Testing Tool Online | LambdaTest"; System.out.println("Verifying the title of the webpage started"); Assertions.assertEquals(expectedTitle, actualTitle); System.out.println("The webpage has been launched and the title of the webpage has been veriified successfully"); System.out.println("********Execution of "+methodName+" has ended********"); } @ Test @ DisplayName("Login_Test") @ Tag("Sanity") public void login_Test() { String methodName = Thread.currentThread() .getStackTrace()[1] .getMethodName(); System.out.println("********Execution of "+methodName+" has been started********"); System.out.println("Launching LambdaTest website started.."); driver.get(urlToTest); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); WebElement login = driver.findElement(By.xpath("//a[text()='Login']")); login.click(); WebElement username = driver.findElement(By.xpath("//input[@ name="email"]")); WebElement password = driver.findElement(By.xpath("//input[@ name="password"]")); WebDriverWait wait = new WebDriverWait(driver,20); wait.until(ExpectedConditions.visibilityOf(username)); username.clear(); username.sendKeys("acvdd@ gmail.com"); password.clear(); password.sendKeys("abc@ 123"); WebElement loginButton = driver.findElement(By.xpath("//button[text()='Login']")); loginButton.click(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); String actual = driver.getTitle(); String expected = "Welcome - LambdaTest"; Assertions.assertEquals(expected, actual); System.out.println("The user has been successfully logged in"); System.out.println("********Execution of "+methodName+" has ended********"); } @ Test @ DisplayName("Logo_Test") public void logo_Test() { String methodName = Thread.currentThread() .getStackTrace()[1] .getMethodName(); System.out.println("********Execution of "+methodName+" has been started********"); System.out.println("Launching LambdaTest website started.."); driver.get(urlToTest); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); System.out.println("Verifying of webpage logo started.."); WebElement logo = driver.findElement(By.xpath("//*[@ id="header"]/nav/div/div/div[1]/div/a/img")); boolean is_logo_present = logo.isDisplayed(); if(is_logo_present) { System.out.println("The logo of LambdaTest is displayed"); } else { Assertions.assertFalse(is_logo_present,"Logo is not present"); } System.out.println("********Execution of "+methodName+" has ended********"); } @ Test @ DisplayName("Blog_Test") public void blogPage_Test() { String methodName = Thread.currentThread() .getStackTrace()[1] .getMethodName(); System.out.println("********Execution of "+methodName+" has been started********"); System.out.println("Launching LambdaTest website started.."); driver.get(urlToTest); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); WebElement resources = driver.findElement(By.xpath("//*[text()='Resources ']")); List options_under_resources = driver.findElements(By.xpath("//*[text()='Resources ']/../ul/a")); boolean flag = resources.isDisplayed(); if(flag) { System.out.println("Resources header is visible in the webpage"); Actions action = new Actions(driver); action.moveToElement(resources).build().perform(); WebDriverWait wait=new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources)); for(WebElement element : options_under_resources) { if(element.getText().equals("Blog")){ System.out.println("Clicking Blog option has started"); element.click(); System.out.println("Clicking Blog option has ended"); driver.manage().timeouts().pageLoadTimeout(20,TimeUnit.SECONDS); Assertions.assertEquals("LambdaTest Blogs", driver.getTitle()); break; } else Assertions.fail("Blogs option is not available"); } } else { Assertions.fail("Resources header is not visible"); } System.out.println("********Execution of "+methodName+" has ended********"); } @ Test @ DisplayName("Cerification_Test") public void certificationPage_Test() { String methodName = Thread.currentThread() .getStackTrace()[1] .getMethodName(); System.out.println("********Execution of "+methodName+" has been started********"); System.out.println("Launching LambdaTest website started.."); driver.get(urlToTest); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); WebElement resources = driver.findElement(By.xpath("//*[text()='Resources ']")); List options_under_resources = driver.findElements(By.xpath("//*[text()='Resources ']/../ul/a")); boolean flag = resources.isDisplayed(); if(flag) { System.out.println("Resources header is visible in the webpage"); Actions action = new Actions(driver); action.moveToElement(resources).build().perform(); WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources)); for (int i = 0; i < options_under_resources.size(); i++) { String value = options_under_resources.get(i).getText(); if (value.equals("Certifications")) { System.out.println("Clicking Certifications option has started"); action.moveToElement(options_under_resources.get(i)).build().perform(); options_under_resources.get(i).click(); System.out.println("Clicking Certifications option has ended"); driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS); String expectedCertificationPageTitle = "LambdaTest Selenium Certifications - Best Certifications For Automation Testing Professionals"; String actualCertificationPageTitle = driver.getTitle(); Assertions.assertEquals(expectedCertificationPageTitle, actualCertificationPageTitle); break; } } } System.out.println("********Execution of "+methodName+" has ended********"); } @ Test @ DisplayName("Support_Test") public void supportPage_Test() { String methodName = Thread.currentThread() .getStackTrace()[1] .getMethodName(); System.out.println("********Execution of "+methodName+" has been started********"); System.out.println("Launching LambdaTest website started.."); driver.get(urlToTest); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); WebElement supportHeader = driver.findElement(By.xpath("(//div//*[text()='Support'])[1]")); boolean flag = supportHeader.isDisplayed(); if(flag) { System.out.println("support header is visible in the webpage"); supportHeader.click(); } else { Assertions.fail("support header is not visible"); } System.out.println("********Execution of "+methodName+" has ended********"); } @ AfterEach public void tearDown() { System.out.println("Quitting the browsers has started"); driver.quit(); System.out.println("Quitting the browsers has ended"); } @ AfterAll public static void end() { System.out.println("Tests ended"); } }
selenium-cucumber related posts
-
JUnit Tutorial: An Inclusive Guide [With Enhanced Features]
-
Top 28 Selenium WebDriver Commands in NUnit For Test Automation
-
How to Handle iFrames in Playwright
-
How To Use Playwright How To Use Playwright For Web Scraping with Python
-
Exception Handling In Cypress: A Comprehensive Guide
-
Perform Easy Cross Browser Testing With LambdaTest WordPress Plugin
-
How To Use Arrays.asList() In Java [With Examples]
-
A note from our sponsor - InfluxDB
www.influxdata.com | 23 May 2024
Index
Project | Stars | |
---|---|---|
1 | NodeJs-Cucumber-Selenium | 20 |
Sponsored