Java 如何使用SeleniumWebDriver根据值确定单选按钮选择?

Java 如何使用SeleniumWebDriver根据值确定单选按钮选择?,java,selenium,radio-button,webdriver,Java,Selenium,Radio Button,Webdriver,我正在尝试确定选择了两个单选按钮中的哪一个,并基于此选择另一个。我正在使用Java和selenium 我的HTML是: <div class="row span-670px"> <h3>Turn on</h3> <div class="field-row"> <div class="field-wrap radio-row clearfix "> <input type="radio" name="choo

我正在尝试确定选择了两个单选按钮中的哪一个,并基于此选择另一个。我正在使用Java和selenium

我的HTML是:

<div class="row span-670px">
<h3>Turn on</h3>
<div class="field-row">
    <div class="field-wrap radio-row clearfix ">
        <input type="radio" name="choosePaymentModel" value="QUOTEHOLD" checked="checked" />
        <label>
            ...
        </label>
    </div>
</div>

打开
...


关掉
...

唯一不同的是value属性。选中的属性将根据选中的属性进行更改,因此区分这两个属性的唯一清晰方法是按值。我似乎找不到正确的语法来抓取正确的单选按钮。当使用IDE时,元素标识符根据选择相互交换,因此没有任何东西是唯一的

建议

我不得不使用:

element = driver.findElement(By.xpath("//input[@name='choosePaymentModel' and @value='QUOTEHOLD']"));

来确定选择了哪个,但不幸的是,单击方法对它们不起作用

在玩IDE时,幸运的是找到了两个单独的bizzare元素可供单击,它们实际上并不是包含“isSelected”值的元素

不管是哪种情况,看起来我找到了自己问题的答案

String tempvalue[]=object.split(Concrete.VALUE_SPLIT);
//here I am splitting the values passed through data sheet against radio buttons                
String Val_radio =Browser.driver.findElement(By.xpath(OR.getProperty(tempvalue[0])+data+OR.getProperty(tempvalue[1]))).getAttribute("value");
System.out.println(Val_radio);
Boolean radio = Browser.driver.findElement(By.xpath("//input[@name='radio' and @value="+"'"+Val_radio+"'"+"]")).isSelected();
if(radio.booleanValue()==true){

//do something here

}
element = driver.findElement(By.xpath("//input[@name='choosePaymentModel' and @value='BASIC']"));
String tempvalue[]=object.split(Concrete.VALUE_SPLIT);
//here I am splitting the values passed through data sheet against radio buttons                
String Val_radio =Browser.driver.findElement(By.xpath(OR.getProperty(tempvalue[0])+data+OR.getProperty(tempvalue[1]))).getAttribute("value");
System.out.println(Val_radio);
Boolean radio = Browser.driver.findElement(By.xpath("//input[@name='radio' and @value="+"'"+Val_radio+"'"+"]")).isSelected();
if(radio.booleanValue()==true){

//do something here

}