简体   繁体   English

“它”之外的任何代码均不适用于量角器

[英]Any code outside 'it' doesn't work with Protractor

I used protractor as a scraping tool (like https://github.com/motemen/example-scrape-websites/blob/master/protractor/mufg.js ) but today my code has changed to be impossible to work. 我使用了量角器作为抓取工具(例如https://github.com/motemen/example-scrape-websites/blob/master/protractor/mufg.js ),但是今天我的代码已更改为无法使用。

I spent a long time to find the reason, and found that any code outside 'it' sentence doesn't work. 我花了很长时间找到原因,发现'it'语句之外的任何代码都不起作用。

describe( 'Start Scraping', function () {

  // Use Protractor with the site which doesn't use AngularJS
  browser.ignoreSynchronization = true;

  /*
   * Fail because not inside of 'it' sentence
   */
  browser.get( 'http://www.google.com' );

Is this change inevitable? 这是不可避免的吗? Do I have to give up Protractor-Scraping? 我是否必须放弃量角器刮取?

Biggest probrem is variable definition because the variable between multiple 'it' sentence is impossible. 最大的问题是变量定义,因为多个“ it”语句之间的变量是不可能的。

You should be able to add browser.ignoreSynchronization = true; 您应该能够添加browser.ignoreSynchronization = true; to a beforeEach block, but your browser related code will have to go in an it block. beforeEach块,但是与browser相关的代码将必须放入it块。 This is due to the way that protractor queues up browser requests. 这是由于量角器将浏览器请求排队的原因。

I'd personally use nightmare or phantom for web scraping. 我个人会使用噩梦或幻影进行网页抓取。 You're going to be fighting protractor a lot to use it for anything but integration tests (I fight it even when I do integration testing ^^) 除了集成测试之外,您将经常与量角器进行斗争以将其用于其他任何事情(即使进行集成测试也要与之抗衡^^)

The reason why Protractor test doesn't work recently is bug of latest Chrome driver. 量角器测试最近不起作用的原因是最新的Chrome驱动程序的错误。 You can run test with Firefox! 您可以使用Firefox进行测试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM