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

Update click.js for relative selectors #2747

Merged
merged 5 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/actions/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ async function simulateInputEvents(options) {
}

async function click(selector, options = {}, ...args) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add a unit test for this case ?

describe("With proximity selector", () => {
a case with other click option and proximity selector

let allOptions = options;
let allOptions = args;
if (options instanceof RelativeSearchElement) {
allOptions = [options].concat(args);
}
const clickOptions = setClickOptions(allOptions);
const clickOptions = setClickOptions(options);
clickOptions.noOfClicks = clickOptions.clickCount || 1;

if (isSelector(selector) || isString(selector) || isElement(selector)) {
Expand Down
16 changes: 16 additions & 0 deletions test/unit-tests/click.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe(test_name, () => {
<input onclick="displayText('Click works with text as value.')" value="Text as value"/><br/>
<input onclick="displayText('Click works with text as type.')" type="Text as type"/><br/>
<span onclick="displayText('Click works with proximity selector.')">Click with proximity</span>
<span onclick="displayText('Click works with proximity selector and options object.')">Click with proximity and options object</span>
<div onclick="displayText('Click works with text accross element.')">
Text <span>accross</span> elements
</div>
Expand Down Expand Up @@ -154,6 +155,21 @@ describe(test_name, () => {
});
});

describe("With proximity selector and options object", () => {
it("should click", async () => {
await click(
"Click with proximity and options object",
{ waitForNavigation: true },
below("Proximity marker"),
);
expect(
await text(
"Click works with proximity selector and options object.",
).exists(),
).to.be.true;
});
});

describe("Text accross element", () => {
it("should click", async () => {
await click("Text accross elements");
Expand Down
Loading