Javascript 我需要验证coveo搜索中的建议列表是否正确
所以,是的,我试着通过Selenium中的css选择器来定位suggestion magic box,试着发送DOWN键来选择建议值,试着通过JavaScript找到元素的标记,但没有任何帮助。 我只发现元素就在这里的某个地方 div[class='magic-box-suggestion coveo omnibox可选']Javascript 我需要验证coveo搜索中的建议列表是否正确,javascript,java,selenium,autosuggest,coveo,Javascript,Java,Selenium,Autosuggest,Coveo,所以,是的,我试着通过Selenium中的css选择器来定位suggestion magic box,试着发送DOWN键来选择建议值,试着通过JavaScript找到元素的标记,但没有任何帮助。 我只发现元素就在这里的某个地方 div[class='magic-box-suggestion coveo omnibox可选'] 但尝试从该元素获取所有子元素时返回0个元素。我试图用谷歌搜索那个问题,但什么也没找到 我有办法了!我们到了: driver.findElements(By.xpath("/
但尝试从该元素获取所有子元素时返回0个元素。我试图用谷歌搜索那个问题,但什么也没找到 我有办法了!我们到了:
driver.findElements(By.xpath("//div[./span[@class='coveo-omnibox-hightlight']]"));
这段代码返回一个列表,该列表包含Coveo魔术盒建议中的所有span元素
这个JavaScript代码帮助我为Coveo的autosuggestion查询找到了一个定位器。只需在浏览器控制台中执行此操作
// 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);
分享html代码以及迄今为止您在代码中尝试过的内容。