Page 1 of 1

How to identify text control by placeholder attribute

Posted: Wed Mar 20, 2013 12:27 pm
by mkeeley
Hi,

I would like to identify a textbox (UITextField in iOS) by its "placeholder" attribute (the greyed out text visible before you enter anything).

I tried setting the XPath to /form/container/text[@placeholder='username'] for example, but it does not find the element.


Also, I could not seem to validate this property either (using an Xpath that works, like text[1]):
Validate.Attribute(repo.DemoRX.SomeContainer.UsernameInfo, "placeholder", "username");
Attribute 'placeholder' of element for item 'DemoRXRepository.DemoRX.SomeContainer.Username' does not match the specified value (actual='(null)', expected='username').

Is there any way of accessing the "placeholder" property? From code?

Re: How to identify text control by placeholder attribute

Posted: Thu Mar 21, 2013 1:46 pm
by Support Team
Hello,

Is there an entry for this property in the repository item?
You can use IntelliSense in order to check if this property is available for this repository item.
repo.DemoRX.SomeContainer.UsernameInfo.Placeholder
If this is the case you can check the value using an if condition.

Regards,
Bernhard

Re: How to identify text control by placeholder attribute

Posted: Fri Mar 22, 2013 9:19 am
by mkeeley
It doesn't seem to have this attribute.
My code:

Code: Select all

        	bool found = false;
        	if (repo.DemoRX.SomeContainer.Username.Placeholder == "123")
        		found = true;
        	if (repo.DemoRX.SomeContainer.UsernameInfo.Placeholder == "213")
        		found = true;
Errors:

'Ranorex.Text' does not contain a definition for 'Placeholder' and no extension method 'Placeholder' accepting a first argument of type 'Ranorex.Text' could be found (are you missing a using directive or an assembly reference?) (CS1061)

'Ranorex.Core.Repository.RepoItemInfo' does not contain a definition for 'Placeholder' and no extension method 'Placeholder' accepting a first argument of type 'Ranorex.Core.Repository.RepoItemInfo' could be found (are you missing a using directive or an assembly reference?) (CS1061)


Is there a way of using reflection, or similar method, to access properties not supported by the base Adapter classes?

Re: How to identify text control by placeholder attribute

Posted: Mon Mar 25, 2013 4:13 pm
by Support Team
Hello,

You can also try to use the YourElement.GetAttributeValue("Placeholder") method in order to get the value.
If this will not work please send us a Ranorex Snapshot file in order to analyze the issue in more detail.

Regards,
Bernhard