【问题标题】:I need to verify that suggestion list in coveo's search suggests correctcly [closed]我需要验证 coveo 搜索中的建议列表是否正确建议 [关闭]
【发布时间】:2019-01-31 00:44:57
【问题描述】:

所以,是的,我尝试通过 Selenium 中的 css 选择器定位建议魔法框,尝试发送 DOWN 键来选择建议值,尝试通过 JavaScript 查找元素的标签,但没有任何帮助。 我发现的只是那个元素位于这里的某个地方。

div[class='magic-box-suggestion coveo-omnibox-selectable']

但试图从该元素中获取所有子元素会返回 0 个元素。我试图谷歌这个问题,但没有找到任何东西。

【问题讨论】:

  • 分享html代码以及到目前为止你在代码中尝试过的内容。

标签: javascript java selenium autosuggest coveo


【解决方案1】:

我有办法!我们来了:

driver.findElements(By.xpath("//div[./span[@class='coveo-omnibox-hightlight']]"));

此代码返回 List<WebElement>,其中包含 Coveo 魔术盒建议中的所有 span 元素。

这个 JavaScript 代码帮助我找到了 Coveo 自动建议查询的定位器。只需在浏览器的控制台中执行此操作即可。

// select the target node
var target = document.querySelector('div.magic-box-suggestions');

// create an observer instance
var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
        console.log(mutation);
    });    
});

// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true }

// pass in the target node, as well as the observer options
observer.observe(target, config);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 2019-11-30
    相关资源
    最近更新 更多