-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/TE-17157: Image Actions to support the right click, left click, …
…double right click, double left click action and corrected the android nlps margin value (#51) * Feat[17157]: Image Actions to support the right click, left click, double right click, double left click action and corrected the android nlps margin value * Feat[TE-17157]: Changed the pom xml version.
- Loading branch information
1 parent
56f9606
commit 13cc99e
Showing
10 changed files
with
262 additions
and
7 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
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
85 changes: 85 additions & 0 deletions
85
image_based_actions/src/main/java/com/testsigma/addons/web/DoubleClickOnText.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,85 @@ | ||
package com.testsigma.addons.web; | ||
|
||
import com.testsigma.sdk.ApplicationType; | ||
import com.testsigma.sdk.OCRTextPoint; | ||
import com.testsigma.sdk.Result; | ||
import com.testsigma.sdk.WebAction; | ||
import com.testsigma.sdk.annotation.Action; | ||
import com.testsigma.sdk.annotation.OCR; | ||
import com.testsigma.sdk.annotation.TestData; | ||
import lombok.Data; | ||
import org.openqa.selenium.interactions.Actions; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Action(actionText = "Double click on text name", | ||
description = "Double click on the text using the text coordinates", | ||
applicationType = ApplicationType.WEB) | ||
|
||
public class DoubleClickOnText extends WebAction { | ||
@OCR | ||
private com.testsigma.sdk.OCR ocr; | ||
|
||
@TestData(reference = "name") | ||
private com.testsigma.sdk.TestData text; | ||
|
||
@Override | ||
protected Result execute() { | ||
Result result = Result.SUCCESS; | ||
List<OCRTextPoint> textPoints = ocr.extractTextFromPage(); | ||
printAllCoordinates(textPoints); | ||
OCRTextPoint textPoint = getTextPointFromText(textPoints); | ||
if(textPoint == null) { | ||
result = Result.FAILED; | ||
setErrorMessage("Given text is not found"); | ||
|
||
} else { | ||
logger.info("Found Textpoint with text = " + textPoint.getText() + ", x1 = " + textPoint.getX1() + | ||
", y1 = " + textPoint.getY1() + ", x2 = " + textPoint.getX2() + ", y2 = " + textPoint.getY2()); | ||
clickOnCoordinates(textPoint); | ||
setSuccessMessage("Click operation performed on the text " + | ||
" Text coordinates :" + "x1-" + textPoint.getX1() + ", x2-" + textPoint.getX2() + ", y1-" + textPoint.getY1() + ", y2-" + textPoint.getY2()); | ||
} | ||
|
||
return result; | ||
} | ||
private OCRTextPoint getTextPointFromText(List<OCRTextPoint> textPoints) { | ||
if(textPoints == null) { | ||
return null; | ||
} | ||
for(OCRTextPoint textPoint: textPoints) { | ||
if(text.getValue().equals(textPoint.getText())) { | ||
return textPoint; | ||
|
||
} | ||
} | ||
return null; | ||
} | ||
|
||
private void printAllCoordinates(List<OCRTextPoint> textPoints) { | ||
for(OCRTextPoint textPoint: textPoints) { | ||
logger.info("text =" + textPoint.getText() + "x1 = " + textPoint.getX1() + ", y1 =" + textPoint.getY1() + ", x2 = " + textPoint.getX2() + ", y2 =" + textPoint.getY2() +"\n\n\n\n"); | ||
} | ||
} | ||
public void clickOnCoordinates(OCRTextPoint textPoint) { | ||
|
||
int x1 = textPoint.getX1(); | ||
int y1 = textPoint.getY1(); | ||
int x2 = textPoint.getX2(); | ||
int y2 = textPoint.getY2(); | ||
|
||
// int x = (x1 + x2) / 2; | ||
// int y = (y1 + y2) / 2; | ||
int x = x2; | ||
int y = y2; | ||
|
||
logger.info("MEAN X coordinate: " + x + "\n"); | ||
logger.info("MEAN Y coordinate: " + y + "\n"); | ||
|
||
Actions actions = new Actions(driver); | ||
actions.moveToLocation(x, y).doubleClick().build().perform(); | ||
} | ||
|
||
|
||
} |
85 changes: 85 additions & 0 deletions
85
image_based_actions/src/main/java/com/testsigma/addons/web/DoubleRightClickOnText.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,85 @@ | ||
package com.testsigma.addons.web; | ||
|
||
import com.testsigma.sdk.ApplicationType; | ||
import com.testsigma.sdk.OCRTextPoint; | ||
import com.testsigma.sdk.Result; | ||
import com.testsigma.sdk.WebAction; | ||
import com.testsigma.sdk.annotation.Action; | ||
import com.testsigma.sdk.annotation.OCR; | ||
import com.testsigma.sdk.annotation.TestData; | ||
import lombok.Data; | ||
import org.openqa.selenium.interactions.Actions; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Action(actionText = "Double right click on text name", | ||
description = "Double right click on the text using the text coordinates", | ||
applicationType = ApplicationType.WEB) | ||
|
||
public class DoubleRightClickOnText extends WebAction { | ||
@OCR | ||
private com.testsigma.sdk.OCR ocr; | ||
|
||
@TestData(reference = "name") | ||
private com.testsigma.sdk.TestData text; | ||
|
||
@Override | ||
protected Result execute() { | ||
Result result = Result.SUCCESS; | ||
List<OCRTextPoint> textPoints = ocr.extractTextFromPage(); | ||
printAllCoordinates(textPoints); | ||
OCRTextPoint textPoint = getTextPointFromText(textPoints); | ||
if(textPoint == null) { | ||
result = Result.FAILED; | ||
setErrorMessage("Given text is not found"); | ||
|
||
} else { | ||
logger.info("Found Textpoint with text = " + textPoint.getText() + ", x1 = " + textPoint.getX1() + | ||
", y1 = " + textPoint.getY1() + ", x2 = " + textPoint.getX2() + ", y2 = " + textPoint.getY2()); | ||
clickOnCoordinates(textPoint); | ||
setSuccessMessage("Click operation performed on the text " + | ||
" Text coordinates :" + "x1-" + textPoint.getX1() + ", x2-" + textPoint.getX2() + ", y1-" + textPoint.getY1() + ", y2-" + textPoint.getY2()); | ||
} | ||
|
||
return result; | ||
} | ||
private OCRTextPoint getTextPointFromText(List<OCRTextPoint> textPoints) { | ||
if(textPoints == null) { | ||
return null; | ||
} | ||
for(OCRTextPoint textPoint: textPoints) { | ||
if(text.getValue().equals(textPoint.getText())) { | ||
return textPoint; | ||
|
||
} | ||
} | ||
return null; | ||
} | ||
|
||
private void printAllCoordinates(List<OCRTextPoint> textPoints) { | ||
for(OCRTextPoint textPoint: textPoints) { | ||
logger.info("text =" + textPoint.getText() + "x1 = " + textPoint.getX1() + ", y1 =" + textPoint.getY1() + ", x2 = " + textPoint.getX2() + ", y2 =" + textPoint.getY2() +"\n\n\n\n"); | ||
} | ||
} | ||
public void clickOnCoordinates(OCRTextPoint textPoint) { | ||
|
||
int x1 = textPoint.getX1(); | ||
int y1 = textPoint.getY1(); | ||
int x2 = textPoint.getX2(); | ||
int y2 = textPoint.getY2(); | ||
|
||
// int x = (x1 + x2) / 2; | ||
// int y = (y1 + y2) / 2; | ||
int x = x2; | ||
int y = y2; | ||
|
||
logger.info("MEAN X coordinate: " + x + "\n"); | ||
logger.info("MEAN Y coordinate: " + y + "\n"); | ||
|
||
Actions actions = new Actions(driver); | ||
actions.moveToLocation(x, y).contextClick().pause(100).contextClick().build().perform(); | ||
} | ||
|
||
|
||
} |
85 changes: 85 additions & 0 deletions
85
image_based_actions/src/main/java/com/testsigma/addons/web/RightClickOnText.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,85 @@ | ||
package com.testsigma.addons.web; | ||
|
||
import com.testsigma.sdk.ApplicationType; | ||
import com.testsigma.sdk.OCRTextPoint; | ||
import com.testsigma.sdk.Result; | ||
import com.testsigma.sdk.WebAction; | ||
import com.testsigma.sdk.annotation.Action; | ||
import com.testsigma.sdk.annotation.OCR; | ||
import com.testsigma.sdk.annotation.TestData; | ||
import lombok.Data; | ||
import org.openqa.selenium.interactions.Actions; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Action(actionText = "Right click on text name", | ||
description = "Right click on the text using the text coordinates", | ||
applicationType = ApplicationType.WEB) | ||
|
||
public class RightClickOnText extends WebAction { | ||
@OCR | ||
private com.testsigma.sdk.OCR ocr; | ||
|
||
@TestData(reference = "name") | ||
private com.testsigma.sdk.TestData text; | ||
|
||
@Override | ||
protected Result execute() { | ||
Result result = Result.SUCCESS; | ||
List<OCRTextPoint> textPoints = ocr.extractTextFromPage(); | ||
printAllCoordinates(textPoints); | ||
OCRTextPoint textPoint = getTextPointFromText(textPoints); | ||
if(textPoint == null) { | ||
result = Result.FAILED; | ||
setErrorMessage("Given text is not found"); | ||
|
||
} else { | ||
logger.info("Found Textpoint with text = " + textPoint.getText() + ", x1 = " + textPoint.getX1() + | ||
", y1 = " + textPoint.getY1() + ", x2 = " + textPoint.getX2() + ", y2 = " + textPoint.getY2()); | ||
clickOnCoordinates(textPoint); | ||
setSuccessMessage("Click operation performed on the text " + | ||
" Text coordinates :" + "x1-" + textPoint.getX1() + ", x2-" + textPoint.getX2() + ", y1-" + textPoint.getY1() + ", y2-" + textPoint.getY2()); | ||
} | ||
|
||
return result; | ||
} | ||
private OCRTextPoint getTextPointFromText(List<OCRTextPoint> textPoints) { | ||
if(textPoints == null) { | ||
return null; | ||
} | ||
for(OCRTextPoint textPoint: textPoints) { | ||
if(text.getValue().equals(textPoint.getText())) { | ||
return textPoint; | ||
|
||
} | ||
} | ||
return null; | ||
} | ||
|
||
private void printAllCoordinates(List<OCRTextPoint> textPoints) { | ||
for(OCRTextPoint textPoint: textPoints) { | ||
logger.info("text =" + textPoint.getText() + "x1 = " + textPoint.getX1() + ", y1 =" + textPoint.getY1() + ", x2 = " + textPoint.getX2() + ", y2 =" + textPoint.getY2() +"\n\n\n\n"); | ||
} | ||
} | ||
public void clickOnCoordinates(OCRTextPoint textPoint) { | ||
|
||
int x1 = textPoint.getX1(); | ||
int y1 = textPoint.getY1(); | ||
int x2 = textPoint.getX2(); | ||
int y2 = textPoint.getY2(); | ||
|
||
// int x = (x1 + x2) / 2; | ||
// int y = (y1 + y2) / 2; | ||
int x = x2; | ||
int y = y2; | ||
|
||
logger.info("MEAN X coordinate: " + x + "\n"); | ||
logger.info("MEAN Y coordinate: " + y + "\n"); | ||
|
||
Actions actions = new Actions(driver); | ||
actions.moveToLocation(x, y).contextClick().build().perform(); | ||
} | ||
|
||
|
||
} |