Results 1 to 3 of 3

Thread: Using a conditional to inspect a checkbox value

  1. #1
    Sencha User
    Join Date
    Mar 2017
    Posts
    18
    Vote Rating
    1
      0  

    Default Answered: Using a conditional to inspect a checkbox value

    Type: WebDriver
    ExtJS version:6.5.3.57
    ST 2.2.0.148
    Browser: Chrome v67

    I have a grid that contains multiple tree nodes. Selecting a node will display a form to capture the users information. There is a checkbox on the form that enables or disables the form fields.

    If the checkbox is checked then that means we've already captured their information and I want to bypass step of the test. If it is unchecked then I want to enter the users information using the
    FormDataEntry.enterData(specs.getConsolidatedSpecs());.

    The function I've been working on should take in my stpo locator as the parameter then execute the code within the function. The FormDataEntry.enterData(specs.getConsolidatedSpecs()); is a switch statement that loops through my spec definition to populate forms. That function isn't being called within the it block so I tried passing in the exact locators and actions to perform but haven't been able to successfully check or ignore the checkbox in question.

    (Not sure why the forum is adding additional code tags to my post...)
    Code:
     function cbState2(cbLocator) {
    Code:
           it('It inspects the CB and fills out the form is unchecked', function() {
               cbLocator().execute(function(checkBox) {
                   if(!checkBox.getValue()){
                       //FormDataEntry.enterData(specs.getConsolidatedSpecs());
                       ST.field('checkboxfield[reference="IsEnabled"]').visible().click();
                       ST.field('checkboxfield[reference="IsEnabled"]').checked();
                   }
               });
           });
    
        }

  2. The ".execute" API is for executing a function in the context of the browser, meaning you can't include "ST" APIs within an execute function for WebDriver, as ST will be undefined (it's passed over to the browser to execute).

    I'd suggest doing something like this instead - use the "get" API to get the current checked value of the checkbox, then use "and()" to verify if it's not checked, then run your custom logic to populate other form fields within that:

    Code:
    ST.checkBox('mycheckbox')
        .get('checked')
        .and(function () {
            if (!this.future.data.checked) {
                // Do your custom bits in here if checkbox is not checked
            }
        });

  3. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    213
    Answers
    23
    Vote Rating
    24
      0  

    Default

    The ".execute" API is for executing a function in the context of the browser, meaning you can't include "ST" APIs within an execute function for WebDriver, as ST will be undefined (it's passed over to the browser to execute).

    I'd suggest doing something like this instead - use the "get" API to get the current checked value of the checkbox, then use "and()" to verify if it's not checked, then run your custom logic to populate other form fields within that:

    Code:
    ST.checkBox('mycheckbox')
        .get('checked')
        .and(function () {
            if (!this.future.data.checked) {
                // Do your custom bits in here if checkbox is not checked
            }
        });
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  4. #3
    Sencha User
    Join Date
    Mar 2017
    Posts
    18
    Vote Rating
    1
      0  

    Default

    That works great and thanks for the info regarding how the execute method functions.

Similar Threads

  1. Conditional checkbox model
    By MaduraVirtusa in forum Sencha Architect 2.x: Help & Discussions
    Replies: 1
    Last Post: 21 Jun 2013, 6:48 PM
  2. How can you inspect json store contents?
    By jmacfarlane in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 22 Jul 2011, 6:29 AM
  3. Best way to inspect the DOM and search for Ext Elements?
    By Achim74 in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 13 Jul 2010, 3:17 AM
  4. howto inspect ext object in firebug ?
    By skanan in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 2 Mar 2010, 11:25 PM
  5. {Solved}firebug question - inspect css
    By michaelc in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 4 Apr 2008, 8:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •