Eclipse “Error: Could not find or load main class”

I am executing the below script and having error

 

Error : Could not find or load main class automationFramework.WebDriverCommands4

 

 

package automationFramework;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebDriverCommands4 {

public static void main(String[] args) {

//Create a instance of the firefox driver
WebDriver driver = new FirefoxDriver();

//Put implicit wait
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

//Launch the URL
driver.get(“http://toolsqa.com/automation-practice-form/”);

//Select the de-selected radio button
//Storing all the elements under category ‘SEX’ in the list of web elements
List<WebElement> rdBtn_Sex = driver.findElements(By.name(“sex”));

//Create a boolean variable which holds the value [ True or False ]
boolean bValue = false;

//This statement will return true, in case of the first radio button is selected
bValue = rdBtn_Sex.get(0).isSelected();

//This will check that if the bValue is True means if the first radio button is selected
if(bValue==true) {
//This will select Second radio button, if the first radio button is selected by default
rdBtn_Sex.get(1).click();
}
else {
//If the first radio button is not selected by default, the first will be selected
rdBtn_Sex.get(0).click();

//Select the Third radio button for category ‘Years of Exp’ (Use Id attribute to select Radio button)
WebElement rdBtn_Exp = driver.findElement(By.id(“exp-2”));
rdBtn_Exp.click();

//Check the Check Box ‘Automation Tester’ for category ‘Profession'( Use Value attribute to match the selection)
//Find the Check Box or radio button element by Name
List<WebElement> chBx_Profession = driver.findElements(By.name(“profession”));

//This will tell you the number of Check Boxes are present
int iSize = chBx_Profession.size();
int i;

//Start the loop from first Check Box to last Check Boxes
for(i=0; i<iSize; i++) {
//Store the Check Box name to the string variable, using ‘Value’ attribute
String sValue = chBx_Profession.get(i).getAttribute(“Value”);

//Select the Check Box it the value of the Check Box is same what you are looking for
if(sValue.equalsIgnoreCase(“Automation Tester”)) {
chBx_Profession.get(i).click();

//This will take the execution out of for loop
break;
}
}
//Check the Check Box ‘Selenium IDE’ for category ‘Automation Tool’ (Use cssSelector)
WebElement oCheckBox = driver.findElement(By.cssSelector(“input[value=’Selenium IDE’]”));
oCheckBox.click();

//Kill the browser
driver.close();
}
}
}

Default Asked on August 9, 2018 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.