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

#2635 Add ability to perform click at disabled elements #2636

Merged
merged 5 commits into from Feb 4, 2024

Conversation

asolntsev
Copy link
Member

@asolntsev asolntsev commented Feb 2, 2024

In this PR, we added parameter force to click:

  $("#disabledButton").click();                              // throws exception
  $("#disabledButton").click(usingDefaultMethod().force());  // works silently

@asolntsev asolntsev modified the milestones: 2635, 7.1.0 Feb 2, 2024
@asolntsev asolntsev linked an issue Feb 2, 2024 that may be closed by this pull request
@asolntsev asolntsev self-assigned this Feb 2, 2024
Copy link
Member

@BorisOsipov BorisOsipov left a comment

Choose a reason for hiding this comment

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

.

src/main/java/com/codeborne/selenide/ClickOptions.java Outdated Show resolved Hide resolved
@asolntsev asolntsev force-pushed the feature/2635-click-disabled-elements branch from c9a6d05 to 60d7e69 Compare February 2, 2024 12:33
CHANGELOG.md Outdated
@@ -4,6 +4,7 @@
* #2550 Implement downloading files via CDP or BiDi (#2567) - thanks to Sergey Brit!
* #2612 don't set page load timeout in mobile tests (#2628)
* #2617 User can safely add the same proxy filter many times (#2630)
* #2635 Add ability to perform click at disabled elements (#2636)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* #2635 Add ability to perform click at disabled elements (#2636)
* #2635 Add the ability to skip checks before clicking an element (#2636)

*/
@CheckReturnValue
@Nonnull
public ClickOptions allowDisabled() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public ClickOptions allowDisabled() {
public ClickOptions force() {

@Test
void clickingDisabledButtonMayBeAllowed() {
assertThatNoException().isThrownBy(() ->
$("#submit").click(usingDefaultMethod().allowDisabled())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$("#submit").click(usingDefaultMethod().allowDisabled())
$("#submit").click(usingDefaultMethod().force())

@Test
void doubleClickingDisabledButtonMayBeAllowed() {
assertThatNoException().isThrownBy(() ->
$("#submit").doubleClick(usingDefaultMethod().allowDisabled())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$("#submit").doubleClick(usingDefaultMethod().allowDisabled())
$("#submit").doubleClick(usingDefaultMethod().force())

NB! It's important to call `e.click()`, not `actions.moveToElement(e, 0, 0).click().perform()`
because the latter doesn't check that the element is covered by other element, and doesn't throw "element is not clickable at point. Other element would receive the click" error.
... to avoid the risk that the following click misses the element because it's still moving
@asolntsev asolntsev force-pushed the feature/2635-click-disabled-elements branch from 89f56a4 to a07a9fb Compare February 4, 2024 10:22
Copy link

sonarcloud bot commented Feb 4, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@asolntsev asolntsev merged commit c96aff3 into main Feb 4, 2024
12 of 13 checks passed
@asolntsev asolntsev deleted the feature/2635-click-disabled-elements branch February 4, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to perform click at disabled elements
3 participants