-1

I have a UI that is rendered against the provided JSON in DB. If I change in the JSON how would I know the fields in UI

How I do this in selenium

1
  • Not a complete answer, but why not travel the json and verify using selenium's locators that the element that you expect actually exists?
    – Rsf
    Sep 7 at 11:25
0

If the UI is rendered on the basis of json provided and json file is having the locators that are being rendered then we can fetch them directly from the json and use the same. While providing software testing solutions one need to take care that how we are manipulating and executing the things. We can map the data which is being fetched from the json and depending upon its id or position(index) in the json file. We can refer them and and can use them till sequence is not changed. By mapping the index of locator in the json and fetching its attribute we can fetch them and use them. If still not clear please attach the json file that you are using and UI html screenshot so that we can elaborate it further.

0

This is pseudo-webdriverio-code but it should demonstrate the idea:

const jsonObj = require('../foo.json');

when('I click a thing', async () => {
  // Create a selector based on the json object's data
  var selector = '#' + jsonObj[id];
  browser.$(selector).click();
)};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.