Skip to content

Commit

Permalink
#2635 rename "disabledElementAllowed" to just "force"
Browse files Browse the repository at this point in the history
  • Loading branch information
asolntsev committed Feb 4, 2024
1 parent 4d43ee8 commit 27568f1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +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)
* #2635 Add the ability to skip checks before clicking an element (#2636)
* #2624 fix duplicate authentication (#2626)
* mask BasicAuth password in logs (#2626)
* #2609 detect case when an event collect is reused by different threads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public Point getCenter(WebElement element) {
@Override
@Nonnull
@CheckReturnValue
protected WebElement findElement(WebElementSource locator, boolean disabledElementAllowed) {
protected WebElement findElement(WebElementSource locator, boolean force) {
if (isMobile(locator.driver())) {
return locator.getWebElement();
} else {
return super.findElement(locator, disabledElementAllowed);
return super.findElement(locator, force);
}
}
}
22 changes: 10 additions & 12 deletions src/main/java/com/codeborne/selenide/ClickOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ public class ClickOptions implements HasTimeout {
private final ClickMethod clickMethod;
@Nullable
private final Duration timeout;
private final boolean disabledElementAllowed;
private final boolean force;

protected ClickOptions(ClickMethod clickMethod, int offsetX, int offsetY,
@Nullable Duration timeout,
boolean disabledElementAllowed) {
protected ClickOptions(ClickMethod clickMethod, int offsetX, int offsetY, @Nullable Duration timeout, boolean force) {
this.clickMethod = clickMethod;
this.offsetX = offsetX;
this.offsetY = offsetY;
this.timeout = timeout;
this.disabledElementAllowed = disabledElementAllowed;
this.force = force;
}

@CheckReturnValue
Expand Down Expand Up @@ -78,26 +76,26 @@ public Duration timeout() {
}

@CheckReturnValue
public boolean isDisabledElementAllowed() {
return disabledElementAllowed;
public boolean isForce() {
return force;
}

@CheckReturnValue
@Nonnull
public ClickOptions offsetX(int offsetX) {
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, disabledElementAllowed);
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, force);
}

@CheckReturnValue
@Nonnull
public ClickOptions offsetY(int offsetY) {
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, disabledElementAllowed);
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, force);
}

@CheckReturnValue
@Nonnull
public ClickOptions offset(int offsetX, int offsetY) {
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, disabledElementAllowed);
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, force);
}

/**
Expand All @@ -118,15 +116,15 @@ public ClickOptions offset(int offsetX, int offsetY) {
@CheckReturnValue
@Nonnull
public ClickOptions timeout(Duration timeout) {
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, disabledElementAllowed);
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, force);
}

/**
* @since 7.1.0
*/
@CheckReturnValue
@Nonnull
public ClickOptions allowDisabled() {
public ClickOptions force() {
return new ClickOptions(clickMethod, offsetX, offsetY, timeout, true);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/codeborne/selenide/commands/Click.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public SelenideElement execute(SelenideElement proxy, WebElementSource locator,
default -> throw new IllegalArgumentException("Unsupported click arguments: " + Arrays.toString(args));
};

click(locator.driver(), findElement(locator, clickOptions.isDisabledElementAllowed()), clickOptions);
click(locator.driver(), findElement(locator, clickOptions.isForce()), clickOptions);
return proxy;
}

@Nonnull
@CheckReturnValue
protected WebElement findElement(WebElementSource locator, boolean disabledElementAllowed) {
return disabledElementAllowed ?
locator.findAndAssertElementIsInteractable() :
protected WebElement findElement(WebElementSource locator, boolean force) {
return force ?
locator.getWebElement() :
locator.findAndAssertElementIsClickable();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void failToClickIfButtonIsDisabled() {
@Test
void clickingDisabledButtonMayBeAllowed() {
assertThatNoException().isThrownBy(() ->
$("#submit").click(usingDefaultMethod().allowDisabled())
$("#submit").click(usingDefaultMethod().force())
);
}

Expand All @@ -36,7 +36,7 @@ void failToDoubleClickIfButtonIsDisabled() {
@Test
void doubleClickingDisabledButtonMayBeAllowed() {
assertThatNoException().isThrownBy(() ->
$("#submit").doubleClick(usingDefaultMethod().allowDisabled())
$("#submit").doubleClick(usingDefaultMethod().force())
);
}
}

0 comments on commit 27568f1

Please sign in to comment.