Unable to verify the displayed Label in Login Page - jasmine-node

Can any one help me on this scenario.
Scenario: When user try to login the application with invalid credentials then a alert message is displayed on page it self as "Invalid login credentials" and it gets disappear by itself.
Here I am unable to capture this message for verification. I have tried as following:
msg = element(by.binding("errmsg"));
msg.tomatch('Invalid Login Credentials');
Here is the below code from where I have taken:
<div id="div_InvalidAccess" class="col-lg-8 span_new" ng-show="invalidAccess" style="display: none;">
<label id="errMsg" class="ng-binding">Invalid Login Credentials</label>
</div>

Related

How can I make a powershell script click on or fill an element without a name or and id?

I'm trying to write a powershell script for loggin in automatically on a website (in IE) and managed to fill the user name value based on it's ID but the password field and the login button have no ID at all. Password field has a name but I can't find a way to use that and login button doesn't even have a name on the website.
User name field:
<input tabindex="1" class="beviteliMezo" type="text" id="nev" name="nev" size="20">
As you can see the User name field has an actual ID so it's easy to do. But...
Password field:
<input tabindex="2" class="beviteliMezo" type="password" name="pass" size="20">
I'm trying to fill it like this:
$ie.Document.getElementByID('password field ID...').value = 'myPassword'
Login button:
<input tabindex="4" type="submit" value="Belépés!" class="submit_btn">
I'm trying to click on it like this:
$link=$ie.Document.getElementByID('login button ID...')
$link.click()
Since none of these elements have an ID, that one won't work. Do you have any suggestions?

Prepend a form field response in Angular 2

I'm building a registration form in Angular 2 that asks a user to provide their website's URL before submitting.
When the form is submitted, I need the provided URL to be in the style of "http://www.google.com". To steer the user towards that format, I want the form field to autofill the initial "http://" as soon as the user clicks on the field (or when the user begins typing - either case would be acceptable). Currently I have placeholder text in the field that says "Please provide your website's URL", but I'm having trouble making the "http://" prefix appear when the user actually clicks on the field or starts typing.
Any ideas would be appreciated. Here is what the form field looks like when the user clicks on it. It's contents should switch to "http://" when clicked or typed in. Here is what the code looks like at the moment:
<div class="form-group">
<input
class="form-control"
type="text"
name="companyUrl"
[(ngModel)]="user.companyUrl"
placeholder="Company url"
required pattern='https?://.+'
#companyUrl
>
<div *ngIf="companyUrl.errors && (companyUrl.dirty || companyUrl.touched)" class="text-danger">
<div [hidden]="!companyUrl.errors.required">
Company URL is required.
</div>
<div [hidden]="!companyUrl.errors.pattern">
URL should begin with http:// or https://
</div>
</div>
<div>
Add a function to add the prefix on click event of the input.
Something like below:
<input #companyUrl (click)="addHttpPrefix()" >
And in this function
1. Get the value of companyUrl.
2. Check if it begins with http then skip else prepend with http://
if(companyUrl.indexOf('http') > -1) {
companyUrl = 'http://' + companyUrl;
}
This way when the user initially clicks on the input http:// would be appended.
if the (click) event does not meet your requirement you can try using (change) or other events.

When logging into Facebook through application the page refreshes

The first page of the application passes a value over to the next page using a text box. If the user isn't logged in then it will display a login link that will allow them to do so. Whenever they click the link the page will refresh which drops the value for the variable passed over from the first page.
This is the code for the input box on the first page (HTML)
<form action="verify.php" METHOD=post>
Enter a School:
<input type="text" name="school" />
<INPUT TYPE=SUBMIT VALUE="GO">
</form>
This is the code for the second page to check if they are logged in or not (PHP)
$user = $facebook->getUser();
if ($user == 0){
$loginUrl = $facebook->getLoginUrl();
echo ( '<b>Please Login before proceeding.</b>' );
echo ( '<br />' );
Store the value you need to save before/after login in a session variable, or apprend it to the variables used in your redirect_uri (generated in the getLoginUrl() function)
Bear in mind you'll need to keep the same redirect_uri value when you exchange the code for an access_token in the second step of the server side auth

how to automatically submit a spring security login form using JSP code?

I'm using spring security for normal login form, where users register and then enter their username and password to login. I'm using login with facebook and login with google options, I'm able to authenticate users and finally get user's info like email, first name, last name etc, After logging into either fb/google I'm using fb/google user email(unique) as user name and system generated password as login credentials so that these values will be entered automatically to spring security login form and then if I click on submit button he/she will be able to login and then session handling will be taken care by spring security as in case of normal user who registers in my website.
Since, all the steps described above are automated except last step i.e. submitting the form
I want to automate the last step also using either javascript or JSP. i tried submitting the form using javascript inside JSP but its unable to
<%
if(Success_login_with_facebook/Success_login_with_google)
{
email = fb_email/google_email;
Sql query to get username and password from db using email;//unique row will be returned
uname_db = username;
uname_pass = password;
out.println("<script>document.forms('login').submit();</script>");
}
%>
<div id="autologin" style="display:none">
<form name="f" id='login' action="<c:url value='j_spring_security_check'/>" method="POST" >
User ID <input size=35 type='text' id="first" name='j_username' value='<%=uname_db %>'/>
Password<input size=35 type='password' name='j_password' value='<%=pass_db %>'>
<input type="hidden" name="_spring_security_remember_me" value=true>
<input style="height:30px" name="submit" type="submit" value="Sign In">
</form>
</div>
Your solution should work, but it's missing one thing. You need to make sure that the form exists before trying to submit it wis JavaScript. In your example, you're doing an out.println above the form. Move this to below the form, and the JavaScript should work fine.
The reason why it did not work is because the html form has submit button name as "submit", and if we try to run the javascript document.forms['login'].submit(); it will not submit the form. If the form submit button name is other than 'submit' then it will work.

PayPal Standard not giving option for Check out as Guest

MVC 3 VB.NET applicaiton... Using express checkout with html razor view. I have tried everything mentioned in all of the docs i could google for as well as the ones on paypal's dev network. Our Paypal account is setup to allow users to Check out as Guest without requiring paypal account creation or login. However when users are taken to the paypal site after clicking the checkout button there is no option to check out as guest. I am including my checkout view for reference. Please understand that this is a valid question and do not down vote it. If there is something not clear I will clarify it..
#modeltype xxxxxxx.orderVM
#Code
ViewData("Title") = "CheckOut"
End Code
<p style="text-align:center">Once you complete your transaction you will be redirected back to the site</p>
<p></p>
<p style="text-align:center">We will process your payment within 24 hours at which time you will recieve a confirmation email which you will need for addmission. Along with a PDF attachment in this email which is your parking permit.. Please print and follow the instructions</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p style="text-align: center"> Please Click on the paypal button below to be redirected to the PayPal Site to complete the payment Transaction</p>
<form id="PayPal" name="PayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
#Html.Hidden("cmd", "_cart")
#Html.Hidden("upload", "1")
#Html.Hidden("business", ConfigurationManager.AppSettings("PayPalMerchantEmail"))
#Html.Hidden("page_style","primary")
#Html.Hidden("custom", Model.id.ToString)
#Html.Hidden("image_url", "http://www.xxxxxxxxxx.com/content/images/xxxxxxxxLogo.jpg")
#Html.Hidden("cpp_header_image", "http://www.xxxxxxxx.com/content/images/xxxxxxxLogo.jpg")
#Html.Hidden("cpp_logo_image", "http://www.xxxxxxxxxxe.com/content/images/xxxxxxxLogo.jpg")
#Html.Hidden("return", "http://www.xxxxxxxxxx.com/")
#Html.Hidden("cancel_return", "http://www.xxxxxxxxxx.com")
#Html.Hidden("first_name", Model.first_name)
#Html.Hidden("last_name", Model.last_name)
#Html.Hidden("address1", Model.address1)
#Html.Hidden("address2", Model.address2)
#Html.Hidden("city", Model.city)
#Html.Hidden("state", Model.state)
#Html.Hidden("zip", Model.zip)
#If Not String.IsNullOrEmpty(Model.Class1) Then
#Html.Hidden("item_name_1", Model.Class1)
#Html.Hidden("amount_1", Model.fee1)
#Html.Hidden("quantity_1", ViewBag.quan)
#Html.Hidden("shipping_1", " 0.00 ")
#Html.Hidden("handling_1", " 0.00 ")
End If
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="middle" style="text-align:center"/>
</form>
I do not feel the code for the controller is required here since it does pass all the values correctly into the view... The only issue is I can not get check out as guest working...
Have you turned on 'Account Optional' in your PayPal Profile?
Which country is your account located in? The guest checkout functionality is not available in all countries yet.