cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript Validation not working

Highlighted
New Contributor

JavaScript Validation not working

I have a simple DejaClick script that hits a web page and then tries to validate there is certain text on the page. When I record the test in DejaClick and use the Keyword Validation tool it finds certain text no problem. But when I replay the script, it fails the validation. I thought I would try to use JavaScript Validation instead. I created a one line JavaScript looking for document.title that returns 'true' when I use the developer tools in Google Chrome, but when I try to use this in DejaClick, it does not appear to return 'true'. Not too familiar with JavaScritpt, so is there something different I need to do in DejaClick to get the script to return 'true'? I am trying to alert on 'true' for testing it out and will then switch to 'false' when it works. Doesn't alert on 'false' either as an FYI. Here is the code:

 

var square = function() { if (document.title == "Home"){ return true; } }; square();

 

Any assistance would be greatly appreciated.

 

JavaScript.jpgJavaScript Validation.jpg

 

2 REPLIES 2
Highlighted
Staff

Re: JavaScript Validation not working

On the original Keyword Validation you created that was not working, try making sure that you are looking for the Keyword in 'All Documents' as opposed to a selected document. You have to be in Advanced display mode to see this option. Try unchecking 'Match Case' and 'Match whole word/phrase' as well.

 

I hope this helps, but if you include the URL I can probably give a JavaScript validation that works too if you need it.

Highlighted
New Contributor

Re: JavaScript Validation not working

Thanks for your reply!  Looks like its just something with how this page is coded.  I used my JavaScript on another site and it worked fine.  I am not able to post the URL since it has credentials embedded in it.  I am just going to have the test alert if it sees certain error messages for validation.  Thanks again.

New Here?
Join us and watch the welcome video:
Announcements