Skip to content

iterate through an array of urls to send to browserstack automate #6

@stelco

Description

@stelco

I’m hoping someone can help with this script as my nodejs skills are only basic. I’m trying to iterate each URL in the .get statement inside module.exports. The 2 console logs at the bottom iterate correctly but not the one inside module.exports.

var urls = [
  {
    "id": "1", 
    "url": "https://www.1.co.uk/"
  },
  {
    "id": "2",
    "url": "https://www.2.co.uk"
  },
  {
     "id":"3",
     "url":"https://www.3.co.uk"
  }
]

// loop through URLs

for (var i = 0; i < urls.length; i++) {
  var obj = urls[i];

  module.exports = {
    name: 'Destinology',
    run: function (browser) {
      return browser
        get(obj.url) // <-- Here
        .sleep(5000)
        .title()
    }
  };

  console.log("id:" + obj.id)
  console.log("url:" + obj.url)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions