0

So I need to test website pigu.lt. I need to change my personal data. Here is my code:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

public class TestSelenium {
    public static void main(String[] args){
        WebDriver driver=new ChromeDriver();
        driver.get("https://pigu.lt/ru/u/login");
        driver.manage().window().maximize();
        WebElement element=driver.findElement(By.name("email"));
        element.sendKeys("qwertyuiop600309@gmail.com");
        WebElement password=driver.findElement(By.name("password"));
        password.sendKeys("Qwerty");

        driver.findElement(By.name("login")).click();

        driver.findElement(By.xpath("//a[@href='u/info']")).click();
        driver.findElement(By.name("name")).sendKeys("Qwerty");
        driver.findElement(By.name("surname")).sendKeys("Qwerty");
        driver.findElement(By.xpath("//input[@id='option1']")).click();

    }
}

And here is the html of the website:

<div class="form-row">
<label>Пол</label>
<div class="pill-swicher">
<input type="radio" value="m" name="sex" id="option1">
<label for="option1">Мужчина</label>
<input type="radio" value="f" name="sex" id="option2">
<label for="option2">Женщина</label>
<input type="radio" value="n" name="sex" checked="" id="option3">
<label for="option3">Не хочу говорить</label>
</div>
</div>

But when I try to select the gender from radio button, it shows that element is not intractable.

1 Answers1

0

The input element is not clickable, you have to click the label element for that input.

This will do the trick:

driver.findElement(By.xpath("//label[@for='option1']")).click();
pburgr
  • 1,722
  • 1
  • 11
  • 26