ruby - Setting/clearing AngularJS md-checkbox with Watir -


i'm trying perform automated testing using watir gem. need test whether checkbox works setting , clearing it.

the html checkbox is:

<md-checkbox aria-label="remove" aria-invalid="false" aria-checked="false" tabindex="0" class="ng-pristine ng-valid md-default-theme ng-touched" role="checkbox" ng-model="user.remove_photo" style="margin-top: 0px;">   <div class="md-container" md-ink-ripple="" md-ink-ripple-checkbox="">     <div class="md-icon"></div>     <div class="md-ripple-container"></div>   </div>   <div ng-transclude="" class="md-label">     <span class="ng-scope">remove</span>   </div> </md-checkbox> 

my test script:

require 'watir' require 'watir-webdriver/wait'    browser =  watir::browser.new :firefox  browser.goto 'https://54.69.254.137/webui#/landing' browser.driver.manage.window.maximize browser.button(:class =>'sign-in md-button md-default-theme').click browser.text_field(:id =>'input_001').set('abcadmin@example.com') browser.text_field(:id =>'input_002').set('password') browser.button(:class =>'md-primary md-raised md-button md-default-theme').click                   browser.button(:class =>'md-icon-button md-primary main-menu-toggle md-button md-default-theme').when_present.click browser.link(:text =>'edit profile').when_present.click browser.checkbox(:class => 'ng-pristine ng-valid md-default-theme-ng-touched').set browser.button(:class => 'md-primary md-raised md-button md-default-theme').click 

gives following error:

unable locate element using checkbox(:class => 'ng-pristine ng-valid md-default-theme- ng-touched').

the problem checkbox is not html checkbox - ie <input type="checkbox">. instead md-checkbox, believe angular material library. result, watir's checkbox method not see it.

you need treat md-checkbox generic element , use click method set/clear it:

browser.element(class: 'ng-pristine ng-valid md-default-theme-ng-touched').click 

the class attribute not unique. might want use 1 of other attributes instead. example:

browser.element(aria_label: 'remove').click 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -