Hi,
i wrote code for selecting partial link text, link text, text box and then radio button.
Earlier code was working fine till text box selection and typing in it.
but now when i include code for radio button, it's throwing exception at text box selection line "NoSuchElementException".
//This code is for launching and closing the browser
package findelement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
public class Browser{
WebElement element;
WebDriver driver;
@BeforeMethod
public void launchBrowser(){
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
driver= new ChromeDriver();
}
@AfterMethod
public void closeBrowser(){
}
}
//Main class
package findelement;
import org.testng.annotations.Test;
@Test
public class Practice extends Browser{
public void practice(){
driver.findElement(By.partialLinkText("Partial Link Test")).click();
driver.findElement(By.linkText("Link Test")).click();
driver.navigate().back();
driver.findElement(By.name("firstname")).sendKeys("Priyanka");
driver.findElement(By.name("lastname")).sendKeys("Sengar");
element = driver.findElement(By.id("sex-1"));
element.click();
}
}
Exception:
FAILED: practice
org.openqa.selenium.NoSuchElementException: no such element
Thanks for anticipating help.