Page 1 of 1

Use of css selector to find object.

Posted: Tue Jun 14, 2016 8:21 am
by FelixK98
Hi Everyone,

I got hybrid app running on iOS on iPod (iOS 9.3.2).
Is it possible to use css selectors as XPaph to access objects?
Does someone have example for use of css selectors with hybrid apps?

Thanks,
Felix.

Re: Use of css selector to find object.

Posted: Tue Jun 14, 2016 8:33 am
by odklizec
Hi,

Could you please upload a Ranorex snapshot from your app?

As long as the css selectors are visible in spy (in 'style' attribute), you should be able to use them in xpath as any other attributes. For example, for HTML code with defined style:
<h1 style="color:blue;">This is a Blue Heading</h1>
You can use this xpath with style attribute:
//body/h1[@innertext='This is a Blue Heading' and @style='color:blue']

Re: Use of css selector to find object.

Posted: Tue Jun 14, 2016 9:05 am
by FelixK98
Hi odklizec,

Yes, please see attachment with snapshot.
My problem with divs that is on this picture:
Spy_win.png
I need to validate innertext attribute for object div[@class='mdl-card__supporting-text pi-accent-one-color']

Thanks,
Felix.

Re: Use of css selector to find object.

Posted: Tue Jun 14, 2016 9:44 am
by odklizec
Hi,

There seems to be no InnerText in the div you mentioned and no style attributes? At least not in the element returned by the xpath I tried:
/mobileapp[@title='au.com.planetinnovation.gidget']//div[@class='mdl-card__supporting-text pi-accent-one-color']
However, there seems to be a number of divs under the returned element. And some of them contain innertext attributes.
Div_InnerText.png
So if the text in these divs are the texts you need to validate, then I'm afraid, you will have to write some custom code to validate them? I mean, using custom code would be most probably the most efficient way to validate these divs. I would suggest to save the parent div (with all its children) as a reference snapshot and then compare it, from code, with the actual one. Check for example this code sample:
http://www.ranorex.com/support/user-gui ... html#c8203
You will of course have to modify it to work with DIVs instead of HTML table.

Re: Use of css selector to find object.

Posted: Tue Jun 14, 2016 10:03 am
by FelixK98
Hi odklizes,

I have problem with divs which are under div selected on picture I attached. If you look down the tree you will find two more divs with the same class attribute.

Anyway, thank you for replay. If you will find some more suggestions I will be happy to see it.

Thanks,
Felix.

Re: Use of css selector to find object.

Posted: Mon Jun 20, 2016 3:30 pm
by Support Team
Hi Felix,

Unfortunately, I'm not exactly sure if this problem is already resolved. It would be great if you could get in touch with me by email ([email protected]) to discuss the problem in more detail.

Thank you.

Regards,
Markus (S)