driver.findElement(By.xpath("//[@class=‘android.widget.EditText’ and ./preceding-sibling::[@text=‘name’]]")).sendKeys(“testname”);
like
driver.findElement(By.xpath("//*[@id=‘editText1’")).sendKeys(“testname”);
driver.findElement(By.xpath("//[@class=‘android.widget.EditText’ and ./preceding-sibling::[@text=‘name’]]")).sendKeys(“testname”);
like
driver.findElement(By.xpath("//*[@id=‘editText1’")).sendKeys(“testname”);
Hi,
You should open the ‘Object Spy’
https://docs.experitest.com/display/public/AS/XPath+Feature
If you find the property you are looking for (in your case ‘id’) then you can use it and it should work.
Be aware that you can control your application in 2 modes: instrumented and non-instrumented. In some cases you will find different properties depend on the mode you are working.
You can find more information about instrumented in the following link:
https://docs.experitest.com/display/public/AS/Preparing+Applications+For+Testing
When i click on “Object Spy” and then on a Element i dont see the case “ID”. I see class, text, enabled, … but no Id.
I use in Andrdoid a “Relative Layout” with no ID and in this Relative Layout is a Button how does it find the Button
If you don’t see an ID it because the element don’t have that property. Why don’t you use text:
xpath=//*[@text=‘Preisliste’]
is Text == ID the same?
No. The text field is related to the presented text to the user. The id is related to internal id provided by the developer (but the ID is not mandatory, so in your case the developer didn’t set it).
yes i didn´t set the id because it is not required. Is it better to use a unique Id to get the elements better?
Yes. because it will also be supported if you change the text or if the application will have to work in different language.