Hi all,
I have a question: Is there a way to input code expression as Input’s data?
For example, I have a method:
@Keyword
def clickElementByXPath(String xpath) {
try {
WebDriver driver = DriverFactory.getWebDriver();
driver.findElement(By.xpath(xpath)).click();
KeywordUtil.markPassed(“Element has been clicked”)
} catch (WebElementNotFoundException e) {
KeywordUtil.markFailed(“Element not found”)
} catch (Exception e) {
KeywordUtil.markFailed(“Fail to click on element”)
}
}
Normally, I will input an xpath: //div//span//a[text()=‘Refugees: Displaced, not discouraged’] in Value field.
I want to make it so that I can input: //div//span//a[text()=‘“+variable+”’] and variable = “Refugees: Displaced, not discouraged” instead.
It is not practical to create methods for each xpath and it is easier to simply change variable instead of changing a whole xpath.
Any help is appreciated. Thank you all beforehand and have a nice day