Check selected radio button - Selenium IDE

I would like to check if a radio button is selected or not with its identifier, for example.

Item to check:

<input id="Evidence_of_Obstruction" class="" type="Radio" checked="" onclick="changeSaveStatus(this, "72");" value="0" name="Patency">
+3
source share
6 answers

Command: assertValue Purpose: name = 'Patentability' Value: on

or something very similar to that. You can use the proposed commands in the Selenium IDE by right-clicking on the switch and selecting one of the commands.

+1
source

Using the Selenium IDE, I prefer item identifiers that would be close to what t3hn00b suggested:

Command: assertValue Purpose: id = Evidence_of_Obstruction Value: on

+1
source

WebDriver :

IWebElement element = _driver.FindElement(By.Id("Evidence_of_Obstruction"));
if(element.Selected)
    ; //then it is selected
else
    ; //then it is NOT selected

, t3hn00b , , Value Checked. :

IWebElement element = _driver.FindElement(By.Id("Evidence_of_Obstruction"));
string result = element.GetAttribute("checked"); // or replace checked with value
//then check the strings contence.
0

:

<tr>
    <td>verifyChecked</td>
    <td>Evidence_of_Obstruction</td>
    <td></td>
</tr>
0

, : -

driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
if(  exists = driver.findElements( By.id("your id") ).size() != 0)
{
    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
}

rhis.

0

- ...

if   |   !selenium.isChecked("Patency")
   waitForElementPresent   |   name=Patency
   click                   |   name=Patency
   waitForValue            |   name=Patency   |   on
endIf

, . , , , . - , -, NAME ID. , , , XPATH CSS, , [xpath ], / .

In the event that your flag does not have any code changes on the web page or for some reason you cannot use either ID or NAME, then you will do something like this:

storeValue   |   xpath=//input[@id="Evidence_of_Obstruction"][@name="Patency"]   |   isBoxChecked
if           |   storedVars['isBoxChecked']=='on'
   goto   |   NEXT_TASK
else
   waitForElementPresent   |   xpath=//input[@id="Evidence_of_Obstruction"][@name="Patency"]
   click                   |   xpath=//input[@id="Evidence_of_Obstruction"][@name="Patency"]
   waitForValue            |   xpath=//input[@id="Evidence_of_Obstruction"][@name="Patency"]   |   on
endIf
label   |   NEXT_TASK

This code uses the Selenium IDE identification flags as unverified (off) or marked (on). You can save the state of the flag and determine what to do with the flag, if anything, based on its current state. Hope this helps you or someone else who is facing this issue.

0
source

All Articles