How to Handling multiple web/mobile elements using xpath?

Unable to capture mobile elements in one xpath.

Hello, please add a further description of your problem.

if a form has multiple inputtext field like --> android.widget.edittext

my script for one input field is given below,
Mobile.setText(findTestObject(‘MobileLoginObejcts/android.widget.EditText0’),“task description”, 0)

if we have mulitple input fields then how to capture those multiple input field in a unique manner or how to write a single xpath which holds all input field of that particular form.


So you want to capture all inputs by single xpath, right? Can I ask you what the reason is?

the reason is , i can put them in as list and provide values into the input fields using code below,


otherwise i need to find unique xpath or objects fora each input field, which is not working.
Which is putting the texts in one field oly , since all input fields have same object name called android.widget.edittext

A better approach would be to define a parameterized xpath that you can populate with the appropriate attribute to find the field you want. For example, maybe all of the fields in your screenshot are <input> elements with a unique id attribute, like this:

<input type="text" id="id1"></id>
<input type="text" id="id2"></id>


Then you could write an xpath like this:


and call each of them from your script like this:

Mobile.setText(findTestObject(‘path/to/test/object’, ['id' : 'id1']),“test”,0)
Mobile.setText(findTestObject(‘path/to/test/object’, ['id' : 'id2']),“test”,0)


But without seeing the HTML for those fields, I can’t provide you a concrete solution.

this is mobile automation, there is no html and all, it will be having android objects.

1 Like

I have the same trouble

can anyone please provide solution to this. Due to this i started hating KS