[英]Determining Radio Button Value Using Selenium WebDriver in Java
I want to know which of the two is radio buttons is selected and based on that select the other one. 我想知道选择了两个单选按钮中的哪个,并根据该选择选择另一个。 The test has to be able to run regardless of which radio button is selected.
无论选择哪个单选按钮,测试都必须能够运行。 I am creating this test with Selenium WebDriver in Java(Eclipse for IDE).
我正在用Java(Eclipse for IDE)中的Selenium WebDriver创建此测试。 From what I understand the only difference between the two is that their values change.
据我了解,两者之间的唯一区别是它们的价值在变化。 I am new to Selenium and Java so I want to understand why the solution is what it is.
我是Selenium和Java的新手,所以我想了解解决方案的实质。
The first radio button has a value of 1 and the second one has a value of 2. I know where they are but don't know exactly how to form this code. 第一个单选按钮的值为1,第二个单选按钮的值为2。我知道它们在哪里,但不确切知道如何形成此代码。
form method="POST" action="switch.do">
<table width="800" cellspacing="0px" cellpadding="7px" border="0">
<tbody>
<tr>
<tr>
<tr class="oddRow">
<td width="30px">
<input type="radio" value="1" checked="" name="masterSelect">
</td>
<td>
<td align="center">
<td align="center">
<td align="center">
<td align="center">
</tr>
<tr class="evenRow">
<td width="30px">
<input type="radio" value="2" name="masterSelect">
</td>
I also see an additional information. 我还看到了其他信息。 The checked radio just populates with
checked=""
attribute. 选中的单选仅填充有
checked=""
属性。 So, I would say find the element with value and use getAttribute()
inside a try catch block to see if that attribute exist or not 因此,我想说的是找到具有值的元素,并在try catch块中使用
getAttribute()
来查看该属性是否存在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.