Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to find TimeField #2740

Open
fhirter opened this issue Oct 10, 2024 · 1 comment
Open

Fails to find TimeField #2740

fhirter opened this issue Oct 10, 2024 · 1 comment

Comments

@fhirter
Copy link

fhirter commented Oct 10, 2024

Describe the bug
It fails to find a TimeField input field.

To Reproduce

await write(time, into(timeField(name.trim(), below(title))));

This results in the following gauge step: Enter "11:00" into the "From" time field below "Time Window"

Logs

Error: TimeField with label From  and below Time Window not found
    at findElements (node_modules/taiko/lib/elementSearch.js:263:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async waitAndGetActionableElement (node_modules/taiko/lib/actions/pageActionChecks.js:150:43)
    at async write (node_modules/taiko/lib/actions/write.js:56:11)
    at async module.exports.write (node_modules/taiko/lib/taiko.js:1064:16)
    at async module.exports.<computed> (node_modules/taiko/lib/taiko.js:2619:14)
    at async Object.<anonymous> (tests/step_implementation.js:143:5

Note the additional space after "From" in the error output. I tried remove whitespace from the variable which did not help. I suspect that it tries to find "From " and fails.

Expected behavior
It should locate the field and input the supplied time.

Screenshots
grafik

Versions:
It runs in a gitlab pipeline using the offical node:20 Docker image based on debian bookworm.

$ npx taiko --version
Version: 1.4.1 (Chromium: 128.0.6597.0) RELEASE
$ gauge -v
Gauge version: 1.6.9
Commit Hash: aff43ef
Plugins
-------
html-report (4.3.1)
js (5.0.0)
screenshot (0.3.0)
$ node -v
v20.18.0

Additional context
It works fine locally on macOS:
taiko:
Version: 1.4.1 (Chromium: 128.0.6597.0) RELEASE

Node v20.16.0

gauge

Plugins
-------
html-report (4.2.0)
js (3.0.1)
screenshot (0.1.0)```

@fhirter
Copy link
Author

fhirter commented Dec 4, 2024

I seem to have found the problem. It fails to find the input field when the input field is nested in the label:

<label>
     board
    <input type="date" id="board-date">
 </label>

when changing to non nested label using for it correctly finds the field:

<label for="board-date>
     board
 </label>
<input type="date" id="board-date">

if any maintainer is reading this, the problem might be in the following code:
https://github.com/getgauge/taiko/blob/master/lib/elementWrapper/timeFieldWrapper.js#L30

the else logic does not seem to work correctly:

    const labelFor = matchingLabel.getAttribute("for");
    if (labelFor) {
      //check label with attribute for
      const labelForElement = searchElement.getElementById(labelFor);
      checkAndPushElement(labelForElement);
    } else {
      // check child node of label tag
      for (const elem of matchingLabel.childNodes) {
        checkAndPushElement(elem);
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant