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

[WIP] Add new action, click each element in list and drag & drop #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

juliensz
Copy link
Collaborator

@juliensz juliensz commented Oct 17, 2019

I add a new function for multi click on page :

  • With a list passed in parameters
  • With se same selector (like class selector ".button")

I add a drag and drop function.

@juliensz juliensz requested a review from vptes1 October 17, 2019 13:30
@chris-bingham
Copy link

Nice, I was going to have to write a drag and drop step, thank you! :)

@@ -148,6 +148,20 @@
}
}

* Click each {{element}} {
if(!Array.isArray(element)){
const elems = await $(element);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you meant to use $$(), which returns multiple elements.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I don't really envision many users passing in an array, as everything in smashtest is a string

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i set a array if people need to set array with multiple element haven't a same Id or class

Copy link
Collaborator

Choose a reason for hiding this comment

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

But it won't be easy for them to set an array. They'd have to set it in a code block using something like g().

Click each [one, two] // NOT an array - this is the string 'one, two'

Easier just to use multiple Click steps in succession.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh ! nice I did not think about doing it like that but it's a great idea a table disguised to make several clicks on items of different name

}
}

* Drag {{dragPosition}} in {{dropPosition}} {
Copy link
Collaborator

@vptes1 vptes1 Oct 20, 2019

Choose a reason for hiding this comment

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

I would reword this as
Drag {{elementFrom}} to {{elementTo}} and Drag {{elementFrom}} to {{x}}, {{y}} (2 different functions)

See dragAndDrop() docs: https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/input_exports_Actions.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok i can reword this and create 2 different functions.

@juliensz
Copy link
Collaborator Author

Not a final function i work on it, i push so that you can see where I am

}

* Drag {{elementFrom}} to {{x}}, {{y}} {
await browser.driver.actions({bridge: true}).dragAndDrop(dragPosition, {x: parseInt(x), y: parseInt(y)}).perform();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variable dragPosition doesn't exist. A unit test would catch that :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry iu didn't test this :)

elems.forEach(elem => elem.click());
}

* Drag {{elementFrom}} in {{elementTo}} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

in --> to

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its good now

@@ -148,6 +148,20 @@
}
}

* Click each {{element}} {
const list = element.split(",");
const elems = await $$(list);
Copy link
Collaborator

Choose a reason for hiding this comment

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

No this isn't right. You had it right before. You shouldn't take a comma-separated list (among many things, the comma is a special character in an EF and this will interfere with that). You just $$(element) and do the forEach() below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok my bad

Copy link
Collaborator

@vptes1 vptes1 left a comment

Choose a reason for hiding this comment

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

This looks really good! Can you add some unit tests to tests/packages/browser.smash?

@juliensz
Copy link
Collaborator Author

yeah i write this test

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

Successfully merging this pull request may close these issues.

3 participants