Skip to content

Commit

Permalink
#3 Add Workarounds for Selenium Functions not working reliable with t…
Browse files Browse the repository at this point in the history
…he new Geckodriver/Firefox

-> Selenium-Functions: sendKeys(Keys.END) & moveToElement(element) do not work reliable with the new Geckodriver (0.28.0) + Firefox (82)
=> Add Workarounds where these functions are causing errors
  • Loading branch information
helkv committed Nov 11, 2020
1 parent 86d10de commit f74ba8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/ui/pages/LibraryPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ public void unlockElement(String elementName) {
WebElement elementLink = this.directoryViewDiv.findElement(By.linkText(elementName));
WebElement elementRow = elementLink.findElement(By.xpath(".//ancestor::tr"));

new Actions(driver).moveToElement(elementRow).perform();
// Selenium sometimes has problems hovering over elements => Use an additional click
new Actions(driver).moveToElement(elementRow).click().perform();
WebElement moreOptions = elementRow.findElement(By.xpath(".//*[@title='More Operations']"));
// Selenium has problems hover/scroll element when clicking => Use JS to click
// Selenium sometimes has problems hover/scroll element when clicking => Use JS to click
((JavascriptExecutor) driver).executeScript("arguments[0].click();", moreOptions);
WebElement unlockFile = elementRow.findElement(By.xpath(".//button[text()='Unlock']"));
unlockFile.click();
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/ui/pages/MarkdownEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ private void addTextToOutline(String outline, String text) {
.findElement(By.xpath("//div[contains(@class,'outline-h2') and text()='" + outline + "']"));
outlineElement.click();
WebElement outlineInput = driver.switchTo().activeElement();
outlineInput.sendKeys(Keys.END);
//Keys.END does not work anymore. Reason unknown.
// outlineInput.sendKeys(Keys.END);
//Workaround: Go to the end of the line with the RIGHT key!
outline.chars().forEach(i -> outlineInput.sendKeys(Keys.RIGHT));
outlineInput.sendKeys(Keys.RETURN);
WebElement beneathOutlineInput = driver.switchTo().activeElement();

Expand Down

0 comments on commit f74ba8c

Please sign in to comment.