-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* BasePage.findImage now returns an implementation of WebElement * Some improvements and fixes in the visual testing demos * Updated to Cucumber 6 (6.7.0) * Updated (almost) all libraries * Improved the quickstart archetype * Updated the documentation * Use Cucumber reporting instead of Cluecumber plugin
- Loading branch information
1 parent
78aa9c4
commit 5690a31
Showing
46 changed files
with
473 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
justtestlah-core/src/main/java/qa/justtestlah/base/ImageWebElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package qa.justtestlah.base; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.JavascriptExecutor; | ||
import org.openqa.selenium.OutputType; | ||
import org.openqa.selenium.Point; | ||
import org.openqa.selenium.Rectangle; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.WebElement; | ||
import qa.justtestlah.stubs.OCR; | ||
|
||
public class ImageWebElement implements WebElement { | ||
|
||
public ImageWebElement(WebDriver driver, Rectangle rect, OCR ocr, String path) { | ||
super(); | ||
this.driver = driver; | ||
this.rect = rect; | ||
this.ocr = ocr; | ||
this.path = path; | ||
} | ||
|
||
protected WebDriver driver; | ||
protected Rectangle rect; | ||
protected OCR ocr; | ||
protected String path; | ||
|
||
@Override | ||
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException { | ||
return (X) new File(path); | ||
} | ||
|
||
@Override | ||
public void click() { | ||
int x = rect.x + rect.width / 2; | ||
int y = rect.y + rect.height / 2; | ||
if (driver instanceof JavascriptExecutor) { | ||
((JavascriptExecutor) driver) | ||
.executeScript( | ||
String.format("el = document.elementFromPoint(%d, %d); el.click();", x, y)); | ||
} | ||
} | ||
|
||
@Override | ||
public void submit() { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public void sendKeys(CharSequence... keysToSend) { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public String getTagName() { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public String getAttribute(String name) { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public boolean isSelected() { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public String getText() { | ||
return ocr.getText(this); | ||
} | ||
|
||
@Override | ||
public <T extends WebElement> List<T> findElements(By by) { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public <T extends WebElement> T findElement(By by) { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
|
||
@Override | ||
public boolean isDisplayed() { | ||
return rect != null; | ||
} | ||
|
||
@Override | ||
public Point getLocation() { | ||
return new Point(rect.x, rect.y); | ||
} | ||
|
||
@Override | ||
public Dimension getSize() { | ||
return new Dimension(rect.width, rect.height); | ||
} | ||
|
||
@Override | ||
public Rectangle getRect() { | ||
return rect; | ||
} | ||
|
||
@Override | ||
public String getCssValue(String propertyName) { | ||
throw new UnsupportedOperationException("operation not supported"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.