Page 1 of 1

Javascript usage with Ranorex

Posted: Mon Aug 12, 2019 8:45 am
by SanMan
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?

Re: Javascript usage with Ranorex

Posted: Mon Aug 12, 2019 8:49 am
by odklizec
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?

Re: Javascript usage with Ranorex

Posted: Mon Aug 12, 2019 8:53 am
by SanMan
Hi,

is it so that Ranorex Spy should show that button in question is not valid?

Re: Javascript usage with Ranorex

Posted: Mon Aug 12, 2019 9:01 am
by SanMan
Bootstrap? What is this and and Ranorex has no problems with it :) ?

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

Should I do the query somewho with this?

Re: Javascript usage with Ranorex

Posted: Mon Aug 12, 2019 9:25 am
by odklizec
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
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?

Re: Javascript usage with Ranorex

Posted: Mon Aug 12, 2019 9:54 am
by SanMan
Hi,

thank you so much for your answer!!

Have to check it out now :) :)