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

Using JQuery functions #26

Open
arunb0405 opened this issue Mar 19, 2019 · 1 comment
Open

Using JQuery functions #26

arunb0405 opened this issue Mar 19, 2019 · 1 comment

Comments

@arunb0405
Copy link

arunb0405 commented Mar 19, 2019

import { ClientFunction } from 'testcafe'; or const {ClientFunction} = require('testcafe');

When I try to use ClientFunction for JQuery in Cucumber-Testcafe frame-work, I get below error.

"ClientFunction cannot implicitly resolve the test run in context of which it should be executed. If you need to call ClientFunction from the Node.js API callback,
pass the test controller manually via ClientFunction's .with({ boundTestRun: t }) method first. Note that you cannot execute ClientFunction outside the test code."

I'm trying to call below JQuery, can you help me how to call it '.with({ boundTestRun: t })'

returnDefValue: ClientFunction(function (pageElem) {
    return document.querySelectorAll(pageElem)[0].value;
}),

After few more tries, I wrapped JQuery in Client function like this :

returnDefValue: function (pageElem, t) {
return ClientFunction(document.querySelectorAll("select[name='dropdown-emailGroupBy']")[0].value).with({ boundTestRun: t });
},

it gives me the response , "ReferenceError: document is not defined"

===

So I'm not able to use the JQuery function with Cucumber, that is usually supported by a Client Function wrapper in testcafe ..

e.g export const returnDefValue = ClientFunction(function (pageElem) {
// window.scrollBy(0, 1000);
return document.querySelectorAll(pageElem)[0].value
});

@rquellh
Copy link
Owner

rquellh commented Apr 2, 2019

Is there anyway that I can fork the project you are working on? It looks like to need to add .with({ boundTestRun: t }) to your selector. Here's an example of when I'm using it https://github.com/rquellh/testcafe-cucumber/blob/master/features/support/pages/github-page.js.

Hope this helps.

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

No branches or pull requests

2 participants