matmanjs / matman

Web 端对端测试(E2E,End-to-End Testing)解决方案
https://matmanjs.github.io/matman
MIT License
45 stars 10 forks source link

爬虫脚本中注入jQuery的优化 #156

Closed helinjiang closed 4 years ago

helinjiang commented 4 years ago

为了简化编写爬虫脚本的难度,当前构建出爬虫脚本时,会默认打入 jQuery,但是会有两种特殊情况有点问题:

情况一,如果目标页面本身已经有jQuery,且可能基于jQuery做了部分开发,此时再注入 jQuery会覆盖之,即便增加了 jQuery.noConflict(); 也可能会有问题,例如 百度首页的例子:

image

情况二,如果目标页面没有加 jQuery,但是针对 $ 有特殊处理时,也会造成问题

image

helinjiang commented 4 years ago

已在 4.0.11 优化,在 matman.config.js 增加 crawlerInjectJQuery 来决定要不要自动打入到爬虫脚本中,默认值为 true