Skip to content
Advertisement

how to make Protractor JavaScript waits for read file to complete?

I put the tested application URL in a text file so I would like Protractor execution to wait without using “Sleep()” method until it finishes reading so Protactor can launch the browser to the website using the text from the file. But so far, Protractor executes so fast so it fails to get the text from the file so it cannot open the website on Chrome

JavaScript

Advertisement

Answer

I have made a solution for you, it gets an URL from a file and opens the link in the browser. My whole solution for you is below.

url-spec.js

JavaScript

conf.js

JavaScript

appURL.txt

JavaScript

Run it by protractor conf.js

Please, do not forget to install fs and protractor for the project. It works really fast. I just run protractor conf.js and it opens the URL in a browser for me.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement