Skip to content
Snippets Groups Projects
Commit a2b6cf25 authored by Manuel Leduc's avatar Manuel Leduc
Browse files

XWIKI-21139: Image size cannot be changed on external URLs

parent 34d277b3
No related branches found
No related tags found
No related merge requests found
......@@ -39,9 +39,14 @@ public class ImageDialogUrlSelectForm extends BaseElement
*/
public void setUrlValue(String url)
{
WebElement iconField = getDriver()
.findElement(By.cssSelector(".image-selector-modal .image-selector .urlTab input[name='urlField']"));
iconField.clear();
iconField.sendKeys(url);
By urlFieldSelector = By.cssSelector(".image-selector-modal .image-selector .urlTab input[name='urlField']");
WebElement urlField = getDriver().findElement(urlFieldSelector);
getDriver().waitUntilElementIsEnabled(urlField);
urlField.clear();
// Wait for the select button to be disabled on the modal before continuing to make sure that the
// set value is taken into account.
getDriver().waitUntilElementIsDisabled(
getDriver().findElement(By.cssSelector(".image-selector-modal button.btn-primary")));
urlField.sendKeys(url);
}
}
......@@ -24,6 +24,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.logging.Level;
import org.openqa.selenium.By;
......@@ -280,7 +281,7 @@ public void waitUntilElementIsVisible(final By locator)
*/
public void waitUntilElementIsVisible(WebElement parentElement, final By locator)
{
waitUntilElementsAreVisible(parentElement, new By[] {locator}, true);
waitUntilElementsAreVisible(parentElement, new By[] { locator }, true);
}
/**
......@@ -452,16 +453,20 @@ public void waitUntilElementHasNonEmptyAttributeValue(final By locator, final St
*/
public void waitUntilElementIsEnabled(WebElement element)
{
waitUntilCondition(driver -> {
try {
return element.isEnabled();
} catch (NotFoundException e) {
return false;
} catch (StaleElementReferenceException e) {
// The element was removed from DOM in the meantime
return false;
}
});
waitUntilCondition(element, WebElement::isEnabled);
}
/**
* Waits until the given element is disabled.
*
* @param element the element to wait on
* @since 15.6RC1
* @since 15.5.1
* @since 14.10.15
*/
public void waitUntilElementIsDisabled(WebElement element)
{
waitUntilCondition(element, Predicate.not(WebElement::isEnabled));
}
/**
......@@ -929,4 +934,18 @@ public Actions moveToTopLeftCornerOfTargetWithOffset(WebElement target, int offs
return chainFrom.moveToElement(target, newOffsetX, newOffsetY);
}
}
private void waitUntilCondition(WebElement element, Predicate<WebElement> condition)
{
waitUntilCondition(driver -> {
try {
return condition.test(element);
} catch (NotFoundException e) {
return false;
} catch (StaleElementReferenceException e) {
// The element was removed from DOM in the meantime
return false;
}
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment