【发布时间】:2020-02-12 23:53:44
【问题描述】:
我有一个功能文件,我在其中将选项卡名称(如 Actions、Workorders、notifications 选项卡)传递给定义选项卡元素及其操作的 pageobjects 类。 如果该选项卡名称不可见,我们必须单击箭头按钮并单击该项目。我将该项目命名为 tabNameItem。不清楚如何在此方法中添加选项卡项名称。以下方法引发错误“然后从选项卡用户单击“accountWorkOrdersTab”#AccountsPageSteps.from_the_tabs_User_clicks_on_tab(WebElement) cucumber.runtime.CucumberException:不知道如何将“accountWorkOrdersTab”转换为 org.openqa.selenium.WebElement。尝试编写自己的转换器:" 调用方式:
@Then("^from the tabs User clicks on \"([^\"]*)\"$")
public void from_the_tabs_User_clicks_on_tab(WebElement tabname) throws Throwable {
serviceCloudAccountsPageObject.openAccountsTabs(tabname);
}
动作类:
@FindBy(xpath = "//a[@text()='Work Order')]")
public WebElement accountWorkOrdersTab;
@FindBy(xpath = "//span[contains(.,'Work Order')]")
public WebElement accountWorkOrdersTabItem;
public void openAccountsTabs(WebElement tabName) {
if(verificationHelper.isDisplayed(tabName)){
tabName.click();
System.out.println(tabName.getText() +" tab displayed & is clicked");
}
else {
moreTab.click();
accountWorkOrdersTabItem.click();
System.out.println("WorkOrder tab not displayed & is clicked from More tab");
}
}
}
【问题讨论】: