Skip to content

Commit

Permalink
QE-9149 remove hardcoded matcher (#339)
Browse files Browse the repository at this point in the history
Issue:

The  radio button is labelled by a **‘text sibling’**.

The label contains leading and trailing spaces.

In ‘fuzzy.js’ matching rules script, the matcher is hardcoded to
**‘has_text’** for finding elements which are labelled by a ‘text
sibling’.

Since the space is not trimmed, it does not match the text and unable to
find the element.

Solution:

Either trim the leading and trailing spaces in the ‘has_text’ custom
matcher

Or

Remove the hard coded matcher, so it can use the **‘contains’** matcher
to match the text and find the element.

Jira Link: https://dominodatalab.atlassian.net/browse/QE-9149

Results:
Loom video of successful run:

https://www.loom.com/share/5323c7a81147415f8c05b1f13098ad51?sid=363a7af2-43e7-4fc5-b194-037e4e32c252


![image](https://github.com/cerebrotech/cucu/assets/91882851/336cd53b-b537-4c2f-b912-755674a8eb4b)
  • Loading branch information
ddl-kavya authored Jun 30, 2023
1 parent 8a6f1cd commit f9bbad0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
15 changes: 13 additions & 2 deletions data/www/radio_buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
</head>
<body>

<label>pick an animal</pick>
<label>pick an animal</label>
<input type="radio" id="cat" name="favorite_animal" value="cat"><label>cat</label>
<input type="radio" id="dog" name="favorite_animal" value="dog"><label>dog</label>
<input type="radio" id="rat" name="favorite_animal" value="rat"><label>rat</label>
</body>

<label> element identified by text sibling with leading and trailing spaces in text</label>
<label>
<input type="radio" id="stateChicago" name="text_sibling">
Chicago
</label>

<label>
<input type="radio" id="stateNewyork" name="text_sibling">
Newyork
</label>
</body>

<div>Same name</div>
<input type="radio" id="blue" name="color" value="blue"><label>blue</label>
Expand All @@ -19,4 +29,5 @@
<input disabled type="radio" id="red" name="favorite_color" value="red"><label>red</label>
<input disabled type="radio" id="green" name="favorite_color" value="green"><label>green</label>
<input disabled type="radio" id="blue" name="favorite_color" value="blue"><label>blue</label>

</html>
10 changes: 10 additions & 0 deletions features/browser/radio_buttons.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ Feature: Radio Buttons
Then I should see the radio button "cat" is not selected
And I should see the radio button "dog" is selected
And I should see the radio button "rat" is not selected

Scenario: User can select a radio button with leading and trailing spaces in name
Given I should see the radio button "Chicago" is not selected
And I should see the radio button "Newyork" is not selected
When I select the radio button "Chicago" if it is not selected
Then I should see the radio button "Newyork" is not selected
And I should see the radio button "Chicago" is selected
When I select the radio button "Newyork" if it is not selected
Then I should see the radio button "Chicago" is not selected
And I should see the radio button "Newyork" is selected
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cucu"
version = "0.142.0"
version = "0.143.0"
license = "MIT"
description = "Easy BDD web testing"
authors = ["Domino Data Lab <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion src/cucu/fuzzy/fuzzy.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
/*
* <*><thing></thing>name</*>
*/
results = jqCucu('*:vis:has_text("' + name + '")', document.body).children(thing + ':vis').toArray();
results = jqCucu('*:vis:' + matcher + '("' + name + '")', document.body).children(thing + ':vis').toArray();
if (cucu.debug) { console.log('<*><thing></thing>name</*>', results); }
elements = elements.concat(results);
}
Expand Down

0 comments on commit f9bbad0

Please sign in to comment.