Najd Mrabet
Najd Mrabet

Reputation: 163

End to end Testing / Run Selenium IDE .json file using webdriver node.js

I have installed Selenium extension of google Chrome Selenium IDE, so I can record my tests and save the test file as .side which is a json file. It contains

{id , command , target , value} .

{     "id": "70a08bcc-b351-4ec6-b64d-f833f09adfa2",
      "name": "Untitled Project",
      "url": "http://example.io",
      "tests": [
        {
          "id": "0b5184ff-4873-459b-b55b-77d56ebf5f6e",
          "name": "Untitled",
          "commands": [
            {
              "id": "35b40ae7-1ada-46d9-8c65-d8faaf1af753",
              "command": "open",
              "target": "/",
              "value": ""
            },
            {
              "id": "0e0bd8b3-4301-4ac6-8cd6-4b01fa94f68d",
              "command": "type",
              "target": "name=login",
              "value": "[email protected]"
            },
            {
              "id": "078da69d-eec3-44b8-b793-53b401a18ac4",
              "command": "clickAt",
              "target": "//div[@id='cloud-ui']/div/div[3]/div/button/span",
              "value": "24,17"
            }...
      

I would like to know if there is solution to run the test file automatically using JavaScript, for example a plugin that reads the file and execute the commands ?

If no, what about create my own JavaScript function that fetch the JSON objects {id, command, target, value} and execute the commands?

for example:

   {
      "id": "512a84b8-c3b0-4cb6-88b4-025d28502f1f",
      "command": "clickAt",
      "target": "css=li.active > a",
      "value": "18,62"
    }

we can run it using selenium-webdriver

  driver.findElement(By.css("li > a > span")).click();

Upvotes: 4

Views: 3860

Answers (0)

Related Questions