Forum Discussion

pratyushgdash's avatar
13 years ago

Unable to select radio button using data driven

This is the application that I am working on.

http://www.automatedqa.com/examples/testcomplete/WebOrders/Process.aspx



I want to select the radio buttons from the excel sheet but I am unable to do it.Can you please let me know how to do it.

I tried with desktop application but here I am unable to do it.It doesn't pull data from the excel sheet for credit card.

Am using keyword testing.

I tried to follow the same methodology for the desktop application and the web app from the help files.



Thanks

Pratyush


  • Hello Pratyush,

    What do you mean by saying that TestComplete does not pull credit cards data from the Excel worksheet? Could you please specify how you are trying to obtain the data? Do any errors occur in your test?

    The approach to selecting radio buttons which is described in our Help system tutorial for the WinForms application may be not quite suitable for the http://www.automatedqa.com/examples/testcomplete/WebOrders/Process.aspx web application. To select radio buttons in the web application, you can follow the instructions below:

    - use If Then operations in your test.

    You can add If Then operations that will compare the values obtained by the data driven variable from the Credit Card column of the Excel worksheet with the hard-coded credit card names and, according to the comparison results, simulate clicks on the corresponding radio buttons.

    - use the FindChild method to select the needed radio button:

      1. First, you need to replace all "AE" entries in the Credit Card column of the sample Excel file with "American Express" entries.

    The next two steps are the same as those described in the 5: Modifying the MasterCard.ClickButton Operation topic of the Data-Driven Testing With Keyword Tests tutorial.

      2. You need to create a project variable, named, for example, RadioButtonName.

      3. Then, you need to add the Set Variable Value operation to your test. In the Select Variable page of the operation dialog, select the created project variable. On the Set New Value page of the dialog, in the Mode box, select Table Data. In the Value box, select Credit Card.

      4. To call the FindChild method that will search for the needed radio button, add the Run Code Snippet operation to your test. Please paste the following code line to the filed on the Specify Code page of the operation dialog:



    Sys.Process("iexplore").Page("http://www.automatedqa.com/examples/testcomplete/WebOrders/Process.aspx").FindChild("value", Project.Variables.RadioButtonName, 20).Click();



    If you use a scripting language other than JScript or if you use a web browser other that Internet Explorer, you will have to modify the script accordingly.

    This script code will call the FinChild method of the web page. The FindChild method will search for the web element whose value equals the value stored in the RadioButtonName project variable and simulate a click on it.


    I hope this information helps you. Please let us know if you have any additional questions.

    Thank you.