1

I am new at selenium testing and facing issue in dynamic page. - the page is a html form but there is no fixed inputypes like it can have input box, radio buttons, like, unlike, combo selections, and multi selections. - depend on the selection of input it may create new input types

2
  • This is something that automation coders often encounter. What is your question? Mar 26 '18 at 13:52
  • my question is how to handle a form inputtypes (those not have fixed xpath) Ex: in a form have yes or no radio button - user selected yes then it newly shows one text box and dropdown box, if user select one item in dropdown box it shows other text area if user select no then it shows other fields finally is depend on selection of input types it newly show other input type so how we can handle this situation
    – Naveen
    Mar 27 '18 at 8:49
1

Use Xpath Axes.

For dynamic locators (Id/name/others), find the pattern of properties created of dynamic objects and then use Xpath Axes to locate based on some stable & static locator in the Dom hierarchy based on it's relationship(Parent, child or sibling) with the dynamic object.

0

Yes, depending on input type you have to use different actions/methods.

Or you can do what we have in our in-house framework: we have input type included in webelement, so generic method fill() can send appropriate value using appropriate method to each input type.

0

The sort of forms you are describing usually have javascript and/or ajax calls to a backend. There may also be the need to wait for the page to render the new elements before checking for them. You can experiment with fixed sleeps to try and help determine the issue but you should do your best to remove them afterwards.

The general stratgey is to use implicit wait, or as I prefer top call them 'polling waits'. For example in Rusby-rspec-selenium these have been incorporated into the capybara gem which sites between rspec and selenium providing a DSL to the selenium interface.

Basically you keep checking the desired output over and over for a given amount of time before declaring element not found. This help address the asynchronous nature of the web by not depending on that nature.

I assume that your form does actually have deterministic paths and subsequent form elements don't just appear 'at random' so I assume you can figure out some fixed workflows to automate.

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.