我正在尝试在FB上创建新帐户,但我无法选择单选按钮和注册按钮
public void f() {
driver.findElement(By.id("u_0_g")).sendKeys("Anamika");
driver.findElement(By.id("u_0_i")).sendKeys("Singh");
driver.findElement(By.id("u_0_l")).sendKeys("9718257931");
driver.findElement(By.id("u_0_s")).sendKeys("P@ssw0rd1");
WebElement add=driver.findElement(By.id("day"));
Select dropDown=new Select(add);
dropDown.selectByIndex(6);
add=driver.findElement(By.id("month"));
dropDown=new Select(add);
dropDown.selectByIndex(4);
add=driver.findElement(By.id("year"));
dropDown=new Select(add);
dropDown.selectByIndex(6);
driver.findElement(By.cssSelector("[id=u_0_j]")).click();
driver.findElement(By.cssSelector("[id=u_0_n]")).click();
//WebElement lstitem=driver.findElement(By.id("u_0_6"));
//driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
//if(elem.isSelected())
//driver.findElement(By.id("u_0_10")).click();
//else
//System.out.println("Button not selected");
}
@BeforeMethod
public void beforeMethod() {
driver=new FirefoxDriver();
driver.get("https://www.facebook.com/");//get to hit the URL
}
@AfterMethod
public void afterMethod() {
//driver.quit();
}
}
获取以下错误:
org.openqa.selenium.ElementNotInteractableException:
答案 0 :(得分:0)
根据FB主页
xPath for female:
//*[@name='sex' and @value='1']
xPath for male:
//*[@name='sex' and @value='2']
答案 1 :(得分:0)
您可以尝试CSS选择器:
女性单选按钮:
input[type='radio'][value='1']
男性单选按钮:
input[type='radio'][value='2']
我已经使用Selenium页面对象模型对其进行了自动化,您可以在github上找到它:https://github.com/prat3ik/Facebook_SignUp_Selenium
路径: / src / test / java /