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

"The element that matches the specified selector is not visible" error on attempt to drag visible element #2799

Closed
samuelsh opened this issue Sep 2, 2018 · 4 comments
Labels
AREA: client STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: automations TYPE: bug The described behavior is considered as wrong (bug).

Comments

@samuelsh
Copy link

samuelsh commented Sep 2, 2018

Are you requesting a feature or reporting a bug?

bug

What is the current behavior?

Trying to drag "seekbar knob" selector raising: "The element that matches the specified selector is not visible" error

What is the expected behavior?

Should be able to perform drag operation

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://kabbalahmedia.info/en/lessons/cu/iIqZE7y7?language=en

Test code

test('timeCodeUpdateByDrag', async t => {

    const getSeekbarRect = ClientFunction((selector) => {
        const {top, left, bottom, right} = document.querySelector(selector).getBoundingClientRect();
        return {top, left, bottom, right};
    });

    await player_utils.waitForPlayerToLoad();
    let rect = await getSeekbarRect('.seekbar__knob');

    console.debug("Rect >> top: " + rect.top + " left: " + rect.left + " bottom: " + rect.bottom +
        " right: " + rect.right);

    let current_mouse_x = rect.left + ((rect.right - rect.left) / 2);
    let current_mouse_y = rect.top + ((rect.top - rect.bottom) / 2);

    const seekbarSelector = await Selector('.seekbar__knob');
    await t.drag(seekbarSelector, current_mouse_x + 100, parseInt(current_mouse_y));

});

Specify your

  • operating system: MacOS HighSierra
  • testcafe version:0.21.1
  • node.js version:9.8
@AndreyBelym AndreyBelym added STATE: Need clarification An issue lacks information for further research. TYPE: bug The described behavior is considered as wrong (bug). AREA: client SYSTEM: automations and removed STATE: Need clarification An issue lacks information for further research. labels Sep 3, 2018
@AndreyBelym
Copy link
Contributor

Hi @samuelsh, I've reproduced the issue. @AlexKamaev, could you please take a look at this?

@AlexKamaev
Copy link
Contributor

Hi @samuelsh
I've found that the element with class .seekbar__knob initially has width and height equal to 0. Since Testcafe considers elements with zero dimensions invisible, it can't initiate a drag action on an invisible element.
To overcome this, define ClientFunction and set the element's width and height inside it to 1.
Please see the example below:

    const setHeight = ClientFunction((selector) => {
        const el = document.querySelector(selector);

        el.style.width = '1px';
        el.style.height = '1px';
    });
    await setHeight('.seekbar__knob');
    await t.drag(seekbarSelector, current_mouse_x + 100, parseInt(current_mouse_y));

@AndreyBelym
Copy link
Contributor

As I see, the problem is that the seekbar knob isn't the <div> element with class seekbar__knob, but a ::before [pseudoelement] of the .seekbar__knob. It's actually a big enhancement, so I close this issue, and you can track progress using the #2813 enhancement issue instead.

Also, you shouldn't calculate knob position with a ClientFunction. The arguments of t.drag are relative to the dragging start point, so you can just use t.drag(seekingKnob, 100, 0).

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: client STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: automations TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants