error in program can someone please help me to get the right result.

85 views
Skip to first unread message

Rajkumar Shahuraje

unread,
Jun 1, 2025, 7:53:01 AMJun 1
to Selenium Users
i am new user with selenium i am facing error 

package raj;


import java.time.Duration;


import org.openqa.selenium.*;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.Select;

import org.openqa.selenium.support.ui.WebDriverWait;


import io.github.bonigarcia.wdm.WebDriverManager;


public class Practice {


public static void main(String[] args) {

WebDriverManager.chromedriver().driverVersion("135.0.7049.115").setup();

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();


try {

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

JavascriptExecutor js = (JavascriptExecutor) driver;


driver.get("https://demoqa.com/automation-practice-form");


// Fill basic details

driver.findElement(By.id("firstName")).sendKeys("Rajkumar");

driver.findElement(By.id("lastName")).sendKeys("Shahuraje");

driver.findElement(By.id("userEmail")).sendKeys("rajkum...@gmail.com");

driver.findElement(By.xpath("//label[@for='gender-radio-1']")).click();

driver.findElement(By.id("userNumber")).sendKeys("9307905613");


// Set Date of Birth

driver.findElement(By.id("dateOfBirthInput")).click();

new Select(driver.findElement(By.className("react-datepicker__month-select"))).selectByVisibleText("January");

new Select(driver.findElement(By.className("react-datepicker__year-select"))).selectByVisibleText("1999");

driver.findElement(By.xpath("//div[@class='react-datepicker__day react-datepicker__day--001']")).click();


// Enter subjects

WebElement subjectInput = driver.findElement(By.xpath("//*[@id=\"subjectsContainer\"]/div"));

subjectInput.sendKeys("Python");

subjectInput.sendKeys(Keys.RETURN);

subjectInput.sendKeys("Data Science");

subjectInput.sendKeys(Keys.ENTER);

subjectInput.sendKeys("Java");

subjectInput.sendKeys(Keys.ENTER);


// Select hobbies

String[] hobbyCheckboxIds = { "hobbies-checkbox-1", "hobbies-checkbox-2", "hobbies-checkbox-3" };

for (String id : hobbyCheckboxIds) {

WebElement checkbox = driver.findElement(By.id(id));

js.executeScript("arguments[0].scrollIntoView(true);", checkbox);

js.executeScript("arguments[0].click();", checkbox);

}


// Fill address

driver.findElement(By.id("currentAddress")).sendKeys("At post nimbhora Tq kannad Dist Chhatrapati Sambhajinagar");


// Select state

WebElement stateDropdown = driver.findElement(By.id("state"));

js.executeScript("arguments[0].scrollIntoView(true);", stateDropdown);

js.executeScript("arguments[0].click();", stateDropdown);


WebElement stateInput = wait.until(ExpectedConditions.elementToBeClickable(By.id("react-select-3-input")));

stateInput.sendKeys("NCR");

stateInput.sendKeys(Keys.ENTER);


// Select city

WebElement cityDropdown = driver.findElement(By.id("city"));

js.executeScript("arguments[0].scrollIntoView(true);", cityDropdown);

js.executeScript("arguments[0].click();", cityDropdown);


wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".css-26l3qy-menu")));


WebElement cityInput = wait.until(ExpectedConditions.elementToBeClickable(By.id("react-select-4-input")));

cityInput.sendKeys("Delhi");

cityInput.sendKeys(Keys.ENTER);


// Submit the form

WebElement submitBtn = driver.findElement(By.id("submit"));

js.executeScript("arguments[0].scrollIntoView(true);", submitBtn);

submitBtn.click();


} catch (Exception e) {

e.printStackTrace();

} finally {

driver.quit();

}

}

}

Adrian

unread,
Jun 1, 2025, 7:28:39 PMJun 1
to Selenium Users
What is the error?
Which line is failing?

ralph van der horst

unread,
Jun 2, 2025, 2:40:02 AMJun 2
to seleniu...@googlegroups.com
yes please provide the output in which it fails

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/db15e165-b9ed-487a-9bb6-1f5f50291525n%40googlegroups.com.

Suriya Elamparithy

unread,
Jul 28, 2025, 7:10:16 AMJul 28
to Selenium Users
package raj;

import java.time.Duration;
import java.util.Arrays;
import java.util.List;
            // Subjects
            List<String> inputSubjects = Arrays.asList("Physics", "Computer Science","Chemistry");
            WebElement subjectInput = driver.findElement(By.id("subjectsInput"));
            for (String subject : inputSubjects) {
                subjectInput.sendKeys(subject);
Reply all
Reply to author
Forward
0 new messages