Javascript usage with Ranorex

Ask general questions here.
SanMan
Posts: 204
Joined: Tue Apr 13, 2010 9:59 am

Javascript usage with Ranorex

Post by SanMan » Mon Aug 12, 2019 8:45 am

Not a coder so hopefully someone can understand what I am trying to explain...

Have a web page and there is a table with buttons.

Image

I need to validate if the button is valid or not.

If I check with Spy, I get that both buttons are Enabled, Valid and Visible. (and button 1 is not)

If I use Chrome F12 and use console, I can get that button one is disabled:

document.querySelector("#DataTables_Table_5 > tbody > tr:nth-child(1) > td:nth-child(5) > a")

a.btn.btn-primary.btn-xs.disabled

How can I do this query with Ranorex user code what I can do in Chrome console?
Attachments
img1.PNG
img1.PNG (1.6 KiB) Viewed 138 times

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

Re: Javascript usage with Ranorex

Post by odklizec » Mon Aug 12, 2019 8:49 am

Hi,

Could you please upload a Ranorex snapshot of the buttons in question? Ideally, can you simulate the problem via https://www.w3schools.com editor?
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

SanMan
Posts: 204
Joined: Tue Apr 13, 2010 9:59 am

Re: Javascript usage with Ranorex

Post by SanMan » Mon Aug 12, 2019 8:53 am

Hi,

is it so that Ranorex Spy should show that button in question is not valid?
Attachments
remove.rxsnp
(123.45 KiB) Downloaded 2 times

SanMan
Posts: 204
Joined: Tue Apr 13, 2010 9:59 am

Re: Javascript usage with Ranorex

Post by SanMan » Mon Aug 12, 2019 9:01 am

Bootstrap? What is this and and Ranorex has no problems with it :) ?

webDocument.ExecuteScript("history.back();");

Should I do the query somewho with this?

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

Re: Javascript usage with Ranorex

Post by odklizec » Mon Aug 12, 2019 9:25 am

Hi,

In my opinion, you don't have to use java script or any code at all. Simply use Validate >> AttributeContains for Class or Safe Class attribute and check the availability of "disabled" string.
BTNDisabled.png
BTNDisabled.png (23.09 KiB) Viewed 120 times
Another possibility is to construct xpath, like this:

Code: Select all

/dom[@domain='br.qa1.noccela.xyz']//table[@id~'DataTables']//a[@class~'disabled']
Then simply use Validate Exists for given repo element with above xpath.

BTW, the above xpath returns multiple disabled buttons! So you may need to make the xpath more specific, by adding the name of line, to which the disabled button belongs?
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

SanMan
Posts: 204
Joined: Tue Apr 13, 2010 9:59 am

Re: Javascript usage with Ranorex

Post by SanMan » Mon Aug 12, 2019 9:54 am

Hi,

thank you so much for your answer!!

Have to check it out now :) :)