Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

How to make browser wait till the urllib post request is complete


#1

We have a application that allows user to login by entering a PIN, This is the first step in the application, this PIN is generated dynamically by a web-service, if a PIN is used once it can’t be re-used again. My requirement is to get the PIN every time by calling the web-service and use it in the synthetics script and check the login. How can I achieve this in scripted browser. Basically I have to send a post request to the API collect the response returned by it and enter that value in the scripted browser

I am able to get the PIN by calling webservice using urllib, but before the request is complete browser is sending keys to the PIN element. How can I sequence urllib request with the browser request


#3

Have you registered a callback function for your urllib call?

urllib.request('http://cnodejs.org/', 
  function (err, data, res) {
    if (!err) {
      // get result of API
      // proceed with browser code...
      $browser.findElement(...);
    }
});