Having Problem with XPATH

Hello guys,

I have one question, well I have captured objects on the web page with the XPATH, but objects are changing often, I mean that what I have capture are not valid anymore. How can I make so that, when developer will change something, I should not be depended on that. Every time developer changes something, I am used to change my objects too.


you can find few tips from one smart guy (:rofl:) here:

1 Like

I will take a look at this, I am sure that, that guy is smart :smiley:

How can I create manually object?

What’s difference between Selected Locator and Object’s Xpaths ?

I had captured this, but it looks, that class was changed to another :smiley: and now I should replace with the new one.

Hi @brithwulf

Selected Locator is the locator that will be used during test execution. Object’s XPaths lists all other locator options for the test object. When generating a test object, first a dozen of XPaths will be generated and the first one will be chosen as the Selected Locator.

You can create a test object manually and call it in your test cases, there’s no difference between calling a test object created by the Web recorder and created manually.

Cheers !

how can I validate with XPATH this disabled ? that div is a button, which is disabled until user fills everything, but developers made mistakes, when entering username and password for some reason that div is not disabled anymore, but if user will type repeat password it changes again to disabled. So on each step I want to validate, if on each step that div is disabled. For example: Validate, set username, Validate, set Password, Validate, set RepeatPassword, Validate if enabled.

EDIT: In object repository, there is not New Object to create new object manually.

WRT disabled attribute - use WebUI.verifyElementHasAttribute(TestObject, attribute, timeout)

WRT manual test object creation - it is meant to be created in test script itself in this way:

TestObject manuallyCreatedTestObject = new TestObject()
int myParameter = 123
String parametrizedXpath = "//div[@id='" + myParameter + "']"
manuallyCreatedTestObject.addProperty('xpath', ConditionType.EQUALS, parametrizedXpath)

The advantage of this approach is that you are able to easily use parametrized XPath (see above)



Another good page with xpath reference and explanation is: https://www.guru99.com/xpath-selenium.html and i Think as more as you practice …more are you going to know on how to identify objects and you will be better in making decisions… and have the better solution to identify objects in general.