Use of css selector to find object.

Mobile Testing, Android App Testing.
User avatar
FelixK98
Posts: 54
Joined: Fri Apr 08, 2016 6:28 am

Use of css selector to find object.

Post by FelixK98 » Tue Jun 14, 2016 8:21 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3945
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Use of css selector to find object.

Post by odklizec » Tue Jun 14, 2016 8:33 am

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']
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
FelixK98
Posts: 54
Joined: Fri Apr 08, 2016 6:28 am

Re: Use of css selector to find object.

Post by FelixK98 » Tue Jun 14, 2016 9:05 am

Hi odklizec,

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

Thanks,
Felix.
Attachments
snapshot5.rxsnp
(61.64 KiB) Downloaded 39 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3945
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Use of css selector to find object.

Post by odklizec » Tue Jun 14, 2016 9:44 am

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
Div_InnerText.png (43.37 KiB) Viewed 1365 times
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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
FelixK98
Posts: 54
Joined: Fri Apr 08, 2016 6:28 am

Re: Use of css selector to find object.

Post by FelixK98 » Tue Jun 14, 2016 10:03 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Use of css selector to find object.

Post by Support Team » Mon Jun 20, 2016 3:30 pm

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)
.
Image