2

To check which input is enable, in our DOM structure(Knockout JS) there is no specific property, which says the button is enable..

Its handled by one of the CSS property, of ::before class :

enter image description here

CSS: {content: "\f013";}

HTML:

<div data-bind="foreach: XXXXXX ">
 <div class=".col-xs-3 col-sm-3 col-md-3 -setting-radio" data-bind="attr: " > 
  <label class="radio-position radio-inline " data-view="widgets/input/radio/view" data-active-view="true" style="">
        <input class="-widgets-input-radio-check" id="radio" type="radio" data-bind="Enable: enable, value: value, checked: checked" value="1" name="FS">
  <span class="-radio-label"></span> 
  <span class="-widgets-input-radio-text" data-bind="html: data">Global</span>
  </label>  
 </div>

 <div class=".col-xs-3 col-sm-3 col-md-3 -setting-radio" data-bind="attr: " > 
  <label class="radio-position radio-inline" data-view="widgets/input/radio/view" data-active-view="true" style=""> 
    <input class="-widgets-input-radio-check" id="radio" type="radio" data-bind="Enable: enable, value: value, checked: checked" value="2" name="FS">
    <span class="-radio-label"> </span>
    <span class="-widgets-input-radio-text" data-bind="html: data">Capital</span> 
  </label>
 </div>  
</div> 

How can we achieve it ?

Ishita Shah
  • 3,955
  • 2
  • 27
  • 51

1 Answers1

0

There is a special method for this in selenium, named value_of_css_property The name differs on the language you use, but the idea is the same.

As I understand from your question you can use it like as in the below example:

assert driver.find_element_by_css_selector('css_locator').value_of_css_property("content") == "\f013"

HTML is not enough, you need to check which CSS properties are changed as well. You can use it to for waits and asserts. I use computed tab for this: enter image description here

vitaliis
  • 4,082
  • 5
  • 18
  • 40
  • Yes, try it. But you have to define which css values are changed by yourself – vitaliis Apr 07 '21 at 14:13
  • Yup, we have to replace with our property. – Ishita Shah Apr 07 '21 at 14:18
  • If the answer will be helpful, accept it ) – vitaliis Apr 07 '21 at 14:20
  • Specific css style getting active on ::before property, What can be CSS selector to locate it ? – Ishita Shah Apr 08 '21 at 07:21
  • In this case check here how to apply JavascriptExecutor https://stackoverflow.com/questions/28244911/selenium-webdriver-get-text-from-css-property-content-on-a-before-pseudo-ele/28265738#28265738 – vitaliis Apr 08 '21 at 12:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/230892/discussion-between-vitaliis-and-ishita-shah). – vitaliis Apr 08 '21 at 12:48
  • Also, check this answer. Maybe your condition changes too fast. You can control the speed of internet https://stackoverflow.com/questions/66927102/trying-to-find-loading-symbols-in-angular/66927506#66927506 – vitaliis Apr 08 '21 at 12:49