javascript - 如何在 LinkedIn 中模拟搜索?
问题描述
我正在尝试在 Javascript 控制台中模拟 Linkedin.com 中的搜索(我需要在 Javascript 中进行,以进行 chrome 扩展开发......而不是在 Phantom、Selenium 或其他浏览器模拟环境中)。
如果我这样做:
document.querySelector(".search-global-typeahead__input").dispatchEvent(new Event('focus', { bubbles: true }))
看起来它就像光标在它上面一样发生了变化(因为它触发了 CSS 行为和字段增长中的某些东西)。
但我无法在输入字段中输入内容。我的尝试:
document.querySelector(".search-global-typeahead__input").dispatchEvent(new KeyboardEvent('keypress',{'key':'a'}));
document.querySelector(".search-global-typeahead__input").dispatchEvent(new KeyboardEvent('keydown',{'key':'a'}));
document.querySelector(".search-global-typeahead__input").dispatchEvent(new Event('change'));
document.querySelector(".search-global-typeahead__input").dispatchEvent(new Event('click'));
...
我可以使用一个简单的“价值”:
document.querySelector(".search-global-typeahead__input").value = "Peter"
但是我怎样才能触发搜索呢?我试过keydowns和其他......
任何想法?
解决方案
推荐阅读
- anylogic - 如何从代码中刷新 AnyLogic ModelDatabase?
- node.js - Node.js child_process STDOUT 不显示进度条
- java - 尝试使用 dpi 保存 tif 时出现奇怪的异常
- javascript - 如果重复,如何比较二维数组中的相邻元素?
- sharepoint - 如何使用sharepoint基础创建动态网站
- flutter - DART,如何一起执行“大于和不等于”?
- angular - Jhipster Angular 应用程序和浏览器列表
- kubernetes - k3s - Metrics server doesn't work for worker nodes
- github - GitHub PR 中的 jenkins 作业状态未按正确顺序显示
- python - Json结构化数据导出CSV