【发布时间】:2018-07-10 07:10:03
【问题描述】:
我正在尝试使用未定义的 get(int) 方法为类型列表创建一个 selenium 脚本,如果未选择,该类型列表将选择一个单选按钮。
我使用以下脚本:
package automationFramework;
import java.awt.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirstTestCase {
public static void main(String[] args) throws InterruptedException {
// Create a new instance of the Firefox driver
System.setProperty("webdriver.gecko.driver", "/home/gradulescu/Documents/Eclipse project/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
// Storing the Application Url in the String variable
String url = "http://toolsqa.wpengine.com/automation-practice-form/";
driver.get(url);
//Launch the Online Store Website
List Rbtn = (List) driver.findElement(By.name("sex"));
boolean bool = false;
bool = Rbtn.get(0).isSelected();
if (bool==true)
{Rbtn.get(1).click();
}
else
{Rbtn.get(0).click();
}
}
}
get方法返回如下错误:
类型列表的方法 get(int) 未定义
我使用带有 JConsole 1.8.0_171-b11 的 Eclipse 3.8.1 和 Java VM 版本:Java HotSpot(TM) 64-Bit Server VM, 25.171-b11
你能帮帮我吗?
【问题讨论】: