无效的选择器:无法找到具有xpath表达式的元素。无法在'文档'上执行'evaluate'

时间:2015-03-06 13:50:38

标签: java xpath

尝试从下拉菜单中选择第二个值。下拉由div类组成。

来自常数类:

public static final String HOME_PAGE_FLYING_FROM_ID = "departureAirport";
public static final String FLYING_FROM_AJAX_XPATH = "//div[contains(@class,'autocompletebox') and (rel,'departureAirport')]/p[2]/a";
来自我的FlightSearch课程的

    @FindBy(how = How.ID, using = HOME_PAGE_FLYING_FROM_ID)
        WebElement flyingFrom;

        @FindBy(how = How.XPATH, using = FLYING_FROM_AJAX_XPATH)
        WebElement flyingFromAjaxValue;

public void simpleFlighSearch() {

        flyingFrom.sendKeys("new");
        action.moveToElement(flyingFromAjaxValue).click().build().perform();
        LOGGER.debug("clicked`");

    }

这是我得到的错误: 无效的选择器:无法找到具有xpath表达式的元素。无法在'文档'上执行'evaluate'。

1 个答案:

答案 0 :(得分:0)

很可能你错过了另一个'包含'和' @'在你的XPath中,它应该是这样的:

//div[contains(@class,'autocompletebox') and contains(@rel,'departureAirport')]/p[2]/a