Call angular function from protractor - html

I'm new to Angular and Protractor.
I'm using protractor to test Angular pages.
I'm trying to test log-in procedure.
part of the html is:
< li data-ng-show="isLoggedIn()" >
I want to make sure that the credentials are correct by calling the 'isLoggedIn()' function.
the 'isLoggedIn()' function is in a controller named 'navControl'.
can I do it? How?
are there other suggestions to test log-in?

You should be testing your log in page (if you are using protractor) like a user - enter some text in your login form, then click the 'Log In' button! After this, inspect the page for whatever elements you are expecting to be visible after a user has logged in. You shouldn't really be directly calling your application functions - testing those falls under unit testing, not e2e testing for which Protractor is designed for :)

Thanks for helping.
The exact phrase I was looking for is this:
expect($('[data-ng-show="isLoggedIn()"]').isDisplayed()).toBeTruthy();

Related

Execute a function once HTML is rendered after web service call - AngularJS

I want to execute a piece of code once view is completely rendered.
Click on button, web service will be called
Once response is received, lot of data will get rendered on ng-repeat
After view is completely rendered, execute a piece of code
I know I can use callback once response is received but HTML rendering might take time. To avoid that I can also write my piece of code in $timeout function but that doesn't feel right approach to me. Any suggestions?
Thanks in advance!

What would be the correct approach for a light AngularJS web-app

I am building a very light Web-App using AngularJS, and i can't seem to find the correct approach as to how to organize it.
To explain it briefly, the App loads a list of objects after the user logs in, and when he choses an object it loads all the detail from that object.
The app (as I am currently building it) will only have to load short JSON text data, so I thought I could have a single page app in a single HTLM file, directed by a single controller who will handle all the data received from the server, and the different views would have been handled by using HTML snippets and AngularJS directives ng-show and ng-includ, like so :
<div ng-show="correctView" ng-include="login_snippet.html >
</div>
<div ng-show="correctView" ng-include="table-view_snippet.html >
</div>
<div ng-show="correctView" ng-include="detail_view_snippet.html >
</div>
The correctView string is changed by the controller to decide which view is to be showned.
Is this a reasonable approach ? I can't seem to find whick one would suit my App best; it doesn't seem to be the right thing to do because the previous button doesnt work with this method, which can't do.
So,
Is there a way to make it so the previous page button would work ?
If not, what would be the correct thing to do ?Is it possible to have several HTML files sharing the same controller ? Or can some controller send data to another ?
I only found examples of single page applications where only parts of the page is changed when the user interacts with it, and this can't do for mine.

Grails Project - Open dialog box

In my application, when I hit Run button which is scripted in gsp page as:
<input type="button" value="Run" onClick="submitJob()"></input>
submitJob() function is defined in a ExtJs JavaScript file which does some operations and calls the controller code which renders a different gsp output page as:
render(template: "/plugin/jobPlot_out", model:[jobName:jobName], contextPath:pluginContextPath)
In my application in web browser it displays the output in the same web page. How to display the same output in a dialog box and not in the same page?
I am new to JavaScript so I posted this question. What I did:
I had to search for the div id of the Run button and had to search for the URL where the div id gets loaded. Upon finding this, I had to write a jQUERY code to open a dialog box and the resulting output was rendered there.
I'm not pretty sure I got you right but have you tried to use a redirect instruction?
http://grails.github.io/grails-doc/3.0.x/ref/Controllers/redirect.html

How to show POP UP window with message using Sikuli webdriver?

I would like to show POP UP with message when my test runs successful. Pls suggest sikuli script for this.
As #autoKarma suggested, you can easily use the popup() function. I have been working with sikuli quite a while. You can see this simple code below.
popup("Display your message here")
That's it. This simple code would serve your purpose.
Goodluck
Have you tried using the popup() function? It is documented here. I don't know anything about sikuli's interaction with webdriver, so take it for whatever its worth.
variable = input("message", "default", "titleOfPopup")

Robot Framework HTML5 - Webdriver support - Webdriver instance of the browser is not able to do login but manually opened browser can

Robot Framework Version 2.8.3
Selenium2Library Version 1.4
The problem which I am facing is with regards to the controls used in the application under test.
Unlike the conventional coding technique of having the controls with ids, my application has been developed by using 'CSS - Class'.
For example a button is coded as :
where the "btn-do-login" is defined in CSS file.
Here when I enter the ids in the username and password fields, I write Click Element btn-do-login
The keyword clicks on the element but does not submits the data to the host as in the case of Submit Form keyword.
Also to mention, the application does not have any form in it. Instead there is a Div with reference to a CSS class.
Following is the entire hierarchy:
<div class="login-form">
<div class="form-element-username"> … </div>
<div class="form-element-password"> … </div>
<div id="btn-do-login" class="wbutton-login"> … </div>
</div>
Any help on how to Post data to the host is appreciated.
Also, please note that, now on entering manually the access credentials on this WebPage opened by Webdriver, and trying to submit it manually still gives me the javascript error and the page is not submitted. For logging in the application manually I need to close the browser instance (opened by Webdriver) and open a new instance manually for manual logging.
And Lastly just wanted to ask whether Selenium2Library supports HTML5 ?
This is what I have done till now.
> Login With Valid Credentials
>> Input Text ${id_login_email} ${country}
>>> Input Text ${id_login_password} ${PASSWD}
>>>> CLick Element btn-do-login
Here the variables have been defined in separate python files and have been imported as VARIABLE in the setting table.
Thanks in advance.
--Raj Sarodaya
After doing quite a few trail and errors I was able to make this work.
The problem with submit was that the javascripts were not loading as my system was behind proxy and I had not set the proxy ip in the browsers.
For many other websites proxy was not required contrary to this case hence it took some time for me to correct it.
:P