Automated browser does not submit form - node.js

I'm currently making automated tests for Browserstack using Selenium and Nightwatch.js. I've encountered a problem where I'm unable to submit a login form. Either nothing happens or the page just reloads. All required login data are set using browser.setValue('{selector}', '{value}'). Tried this on Chrome and Firefox, but the result is the same. I am able to submit the form using JS in browser console, though.
I've tried the following methods to no avail.
browser.submitForm('#login-form');
browser.click('#send2');
browser.execute("document.getElementById('send2').click();");
browser.execute("document.getElementById('login-form').submit();");
Is there anything that I'm missing? If that makes a difference, I'm trying to automate a login form for Magento 1 site.
Much thanks.
Edit:
Added form HTML
<form action="https://{site}/en/customer/account/loginPost/" method="post" id="login-form">
<input name="form_key" type="hidden" value="1CdZGL4mwA0njx3U">
<div class="form-group">
<input type="text" class="input-text-custom required-entry validate-email form-control" id="email" name="login[username]" value="" title="Insert Email Address" placeholder="Insert Email Address">
</div>
<div class="form-group">
<input type="password" class="input-text-custom required-entry form-control" id="pass" name="login[password]" title="Password" placeholder="Password">
</div>
<div class="form-group">
<input type="checkbox" name="nl_subscribe" id="nl_subscribe_existing" value="subscribe" class="form-control checkbox">
<label for="nl_subscribe_existing" class="text-normal-checkout"><span></span>By the way, I also want to subscribe to your newsletter*</label>
</div>
<input type="hidden" name="nl_source" value="customer_login" class="form-control checkbox">
<div class="form-group"><div class="control remember-me-box">
<div class="input-box">
<input type="checkbox" name="persistent_remember_me" class="checkbox" id="remember_meL0h6snrk30" title="Remember Me">
<label for="remember_meL0h6snrk30" class="text-normal-checkout"><span></span>Remember Me</label>
</div>
</div>
</div>
<div class="forgot-password">Forgot password?</div>
<div align="center"><button type="submit" class="button-check" name="send" id="send2" title="log in"><span><span>log in</span></span></button></div>
</form>
Edit 2:
Is it possible that this is related to configuration? I launched this test on local browser and then stopped it, so I could fill and submit the form manually, but I was not able to submit it anyway.

It appears that the script was fine but there was a bug in the site. For some reason, script needs to refresh the browser to be able to submit the form successfully. So, until this is fixed, I've implemented browser.execute('location.reload();'); as a workaround.

Related

Search bar making my web page not trustable

I have a search bar on my website that goes to google but it is making that web page not trustable. I have ssl and all my other pages have the little lock but the page with the search has an i with a circle around it. If i take the search off the page the little lock comes back. Can someone maybe tell me why.
<div class="wrap">
<div class="search">
<form method="get" action="http://www.google.com/search">
<input type="text" name="q" class="searchTerm" placeholder="Search The Web"autocomplete="off" >
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</form>
</div>
</div>

How do I code requirements for a registry and login in Angular

Currently I can log in and register with blank data. I'm not sure how to code a registration "#" symbol that must be present. I'm using Angular.
<form class="form">
<div class="form-group">
<label for="">Username</label>
<input [(ngModel)]="registerUserData.email" name="email" type="text" class="form-control rounded-0" required >
</div>
<div class="form-group">
<label>Passwort</label>
<input [(ngModel)]="registerUserData.password" name="password" type="password" class="form-control rounded-0" required>
</div>
<button (click)="registerUser()" type="button" class="btn btn-primary float-right" routerLink="/special">Register</button>
</form>
There are multiple articles and videos you can follow to perform registration and login in your app. Some of them are
angular 6 user registeration and login
user registration in mean stack using angular 6

Radio button checked not working in the partial view but working in the main view

Radio button checked not working in the partial view. But working in the main view page. also if I use checkbox instead of radio it works fine in the partial view.
Code:-
<label class="radio-inline">
<input type="radio" value="phonetic" name="languageSelector">
<span class="checkmark"></span>Phonetic
</label>
<label class="radio-inline">
<input type="radio" value="bijoy" name="languageSelector">
<span class="checkmark"></span> Bijoy
</label>
<label class="radio-inline">
<input type="radio" value="avro" checked="checked" name="languageSelector">
<span class="checkmark"></span>Avro
</label>
You may be having an issue with the way you're referencing your partial view. There are two ways of doing so:
#Html.Partial("_PartialExample") and #Html.RenderPartial("_PartialExample")
One is written into the HTTP response, the other is rendered as an HTML encoded string. Try both and see if that helps.
Here's more information about what I'm talking about.
https://www.c-sharpcorner.com/UploadFile/ff2f08/partial-view-in-mvc/

$_POST Variable Empty in Quercus Portlet on Liferay 6

My company is migrating from Luminis 5.1 to Luminis 5.3 (both built from Liferay 6), and we're running into a problem where portlets that POSTed fine in 5.1 no longer supply the Post Body in 5.3.
For example, this form
<form id="duplication-request" class="form-horizontal" method="post" enctype="multipart/form-data" action="index.php">
<fieldset>
<legend>General Information</legend>
<div class="form-group">
<label for="name" class="col-sm-4 control-label">Name</label>
<div class="col-sm-8">
<input type="text" id="name" class="form-control" name="name"
value="<?= $input->request->get('name', $name) ?>" required>
</div>
</div>
</fieldset>
<button class="btn btn-primary">Submit</button>
</form>
would supply the $_POST['name'] variable just fine in Luminis 5.1, but in 5.3, not even the 'name' index is registered.
If I serve it locally via php -S 0.0.0.0:8080, the $_POST['name'] variable is registered correctly, leading me to think it's a problem with Quercus (which, unfortunately, isn't well supported)
Are there any settings in web.xml that I need to turn on in order to get Luminis to proxy the Request Body into Quercus so PHP can work with it?

How does Safari know when to prompt user to save password?

This related to How does browser know when to prompt user to save password? except mine is specific to Safari.
I have a website in which there are two different ways you can log in. The first is the main site in which you have to enter your email, password, and your account's domain. The second way is to actually go to your domain (which is pointing at my server) at which point you're only asked to enter in your email and password.
Logging in the second way (two inputs), Safari, Chrome and Firefox will all ask if I'd like to save my username and password (as expected).
But logging in the first way (three inputs), only Chrome and Firefox ask. Safari does not.
My form is not AJAX/Javascript. It has a form tag, a submit button, and three inputs with the ids/names - email, password (of type=password), and account_domain. I do not have autocomplete=off.
Does anyone know what Safari is looking for to ask to save username/passwords? Is it b/c I have three inputs instead of two?
As a note, I ran the same test on my wife's Mac using Safari only and she wasn't prompted to save in either case. So I don't know.
I verified that neither of us had clicked "never remember passwords" for either of these sites.
I was having this same issue, and your post answered my problem.
I just had a simple form that only requested a password, which would not prompt Safari on a mobile to save the password:
<fieldset>
<legend>Please login below:</legend>
<form role="form" id="access" name="access" method="post">
<div class="form-group form-group-sm">
<label for="password">Password</label>
<input class="form-control" required type="password" placeholder="Enter Password" name="password" id="password" />
</div>
<div class="form-group form-group-sm">
<input class="btn-lg btn-primary center-block" type="submit" value="Login" />
</div>
</form>
After reading your post, I added a "username" input field as follows:
<fieldset>
<legend>Please login below:</legend>
<form role="form" id="access" name="access" method="post">
<div class="form-group form-group-sm">
<label for="username">Username</label>
<input class="form-control" required type="text" placeholder="Enter Username" name="username" id="username" />
</div>
<div class="form-group form-group-sm">
<label for="password">Password</label>
<input class="form-control" required type="password" placeholder="Enter Password" name="password" id="password" />
</div>
<div class="form-group form-group-sm">
<input class="btn-lg btn-primary center-block" type="submit" value="Login" />
</div>
</form>
After adding that, I now got a prompt to save the password.
So I think Safari is looking for a username, name, email, etc. to tie along with a password field. I didn't test this too much, but I'm sure someone with more experience can verify that.
Thanks for your post.

Resources