4 Replies Latest reply: Feb 19, 2013 11:12 AM by proven983 RSS

    OpenScript (CheckBox)

    proven983
      Hi,

      I'm building OpenScript for test web functionality. I have a list of the products which show up in the web site. The list have 2 columns, first one is checkbox second one is the name of the product. How can I check/test with openscript if the checkbox in the first column is checked and store the value (text) in the same row from second column to databank/.csv file for later testing in the same script (text match)?

      Thank you!
      NP
        • 1. Re: OpenScript (CheckBox)
          957200
          1. Iterate on each row in the table using a for loop from 0 till rowcount-1

          2. String T_Status=adf.selectBooleanCheckbox(<CHECK BOX XPATH>).getAttribute("selected");
          CHECK BOX XPATH--> IDENTIFY CHECKBOX ID VALUE THATS INCREMENTING WITH ROW NUMBER AND PARAMETERISE IT WITH THE FOR LOOP- VARIABLE

          3. String T_Product = adf.table("{{obj.-------.----------}}").getCell(FOR LOOP- VARIABLE, 1);

          you can save these values to text file.
          Use the same logic to compare with data in text file in next runs.


          hope this solves.
          • 2. Re: OpenScript (CheckBox)
            proven983
            I'm new in OpenScript so I didn't get your post. Can you please describe to me step by step.

            Thank you!

            NP
            • 3. Re: OpenScript (CheckBox)
              Deepu Muraleedharan
              Hi,

              You can do this in different ways. Following are sample code. You can use the following concepts.


              Using getParent and Sibling



                             ArrayList<String> dataArray = new ArrayList<String>();
                             
                             
                             
                             for(int i=0; web
                                       .checkBox(
                                                 "/web:window[@index='0' or @title='Oracle Workflow: Notifications']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_checkbox[@name='N20:selected:"+ i +"']")
                                       .exists();i++){
                                  
                                  
                                  if(web
                                       .checkBox(
                                                 "/web:window[@index='0' or @title='Oracle Workflow: Notifications']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_checkbox[@name='N20:selected:"+ i +"']")
                                       .getAttribute("checked").equalsIgnoreCase("true")){
                                       
                                  dataArray.add(     web
                                       .checkBox(
                                                 "/web:window[@index='0' or @title='Oracle Workflow: Notifications']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_checkbox[@name='N20:selected:"+ i +"']")
                                       .getParent().getNextSibling().getAttribute("text"));
                                       
                                       
                                       
                                  }
                                  
                             }
                             
                             
                             for(int j=0;j<dataArray.size();j++){
                             System.out.println(dataArray.get(j));
                             }

              Note:- Checkbox attribute '@name='N20:selected:"+ i +"'' will be defferent. You can get attributes using inspect path or from DOMTree in Detail View( select wait for page in tree view and see Detail View,you can select DOMTree tab in Detail View)





              Using web.table

                   DOMElement checkBox = null, data = null;
                             ArrayList<String> dataArray = new ArrayList<String>();
                             
                             int count = web.table("/web:window[@index='0' or @title='Oracle Workflow: Notifications']/web:document[@index='0']/web:table[@className='x1h']")
                             .getRowCount();
                             
                             for(int i =2; i<= count;i++){
                                  +// i starts with 2, if you have a row of headers+
                                  List<DOMElement> checkList = web.table("/web:window[@index='0' or @title='Oracle Workflow: Notifications']/web:document[@index='0']/web:table[@className='x1h']")
                                  .getCellElement(i, 1).getElementsByTagName("INPUT");
                                  
                                  checkBox = checkList.get(0);
                                  
                                  if(checkBox.getAttribute("checked").equalsIgnoreCase("true")){
                                       
                                       data = web.table("/web:window[@index='0' or @title='Oracle Workflow: Notifications']/web:document[@index='0']/web:table[@className='x1h']")
                                       .getCellElement(i, 2);
                                       
                                       dataArray.add(data.getAttribute("text"));
                                  }
                                  
                                  
                             }
                             
                             for(int j=0;j<dataArray.size();j++){
                             System.out.println(dataArray.get(j));
                             }


              Note:- In all xpath I mentioned table attribute is 'className = x1h'. You have change it with yours. You can get table attributes using inspect path or from DOMTree in Detail View( select wait for page in tree view and see Detail View,you can select DOMTree tab in Detail View)


              Regards,
              Deepu M
              • 4. Re: OpenScript (CheckBox)
                proven983
                Thank you for your help!