TestProject Forum

Unable to locate element using WebElementAction codeblock using java sdk 0.65.0

HI All,

I am developing addon for my project in which I am passing xpath to my runner class using WebElement along with WebAddonHelper. But when I execute the code I am getting INFO like below:

[pool-2-thread-1] INFO io.testproject.java.sdk.v2.Runner - CodeBlock uses SDK >= 0.65.0, action will have to search for element by provided criteria.

Below is codeblock for getElement(Driver driver, By by)
if (minor < 65 && major <= 0) {
try {
return driver.findElement(by);
} catch (NoSuchElementException var7) {
if (minor <= 53 && (minor != 53 || revision <= 1)) {
log.info(“CodeBlock uses SDK < 0.53.1, throwing exception…”);
throw var7;
} else {
log.info(“Element was not found, action will have to search for it using provided criteria…”);
return null;
}
}
} else {
log.info(“CodeBlock uses SDK >= 0.65.0, action will have to search for element by provided criteria”);
return null;
}

Is it not possible to develop addon using latest open SDK? If yes, what is the reason behind this?

It is really nice feature that we can create addon as per our requirement.

Please suggest your thoughts on the same

Hello @zope.ashish25
Addons have their own designated SDK, which you can download here:
https://app.testproject.io/#/integrations/develop-addon

Since you stated you are using a runner, can you share the code snippet of that runner here please?

I am verifying my addon locally so I created runner class as below:-
Runner class:-
public class ActionRunner extends DriverIO {
private final static String devToken = “my token here(hiding purposely)”;
private static final AutomatedBrowserType BROWSER = AutomatedBrowserType.Chrome;

public static void main(String[] args) throws Exception {
    DriverSettings driverSettings = new DriverSettings(DriverType.Chrome);
        Runner runner = Runner.createWeb(devToken, BROWSER);
        VerifyCellByText verifycell = new VerifyCellByText();
        runner.run(verifycell,By.xpath("//td/div[text()='General']"));
}

}
AddOn Code:-
@Action(name = “Verify Cell”, description = “Verify that {{cellText}} is in the grid”)
public class VerifyCellByText implements WebElementAction {
@Parameter(description = “cellText”)
public String cellText = “”;

@Override
public ExecutionResult execute(WebAddonHelper helper, WebElement element) throws FailureException {
    GridTableBaseAction baseAction = new GridTableBaseAction(helper);
    baseAction.verifyCell(cellText,element);
    return ExecutionResult.PASSED;
}

}

POM File:-

io.testproject.io
java-sdk
0.65.0
${td-path}
system

In here, change it too
baseAction.verifyCell(cellText,helper.getDriver().findElement(helper.getSearchCriteria());

Thank you for your response.