I spent hours looking for, but I couldn't find a solution. I'v to automatize a human job with JS, and I ran some tests in aleatory sites and it works. But in a specific site, i'm having the following problem on the login page:
OBS: I'm doing this in browser console, for tests.
var username = window.document.getElementById("username")
undefined
var password = window.document.getElementById("password")
undefined
var signin = window.document.querySelector(".splButton-primary.btn")
undefined
username.value = "usuariovalue"
"usuariovalue"
password.value = "passwordvalue"
"password value"
signin.click()
but, i'm receiving this msg:>common.js:27 POST https://siteexemple/en-US/account/login 401 (Unauthorized). If I fill the username and password manually in site and after, click on the button using the JS, it works.
I can't see the difference.
Follow the block of code of the site:
<form method="post" class="loginForm" action="/en-US/account/login">
<div style="display: none" data-cid="view200" class="account-login-firsttime" data-view="views/account/login/FirstTime" data-render-time="0">
<h2>First time signing in?</h2>
<p>If you've forgotten your username or password, please contact your Splunk administrator.</p>
<table>
<tbody><tr>
<td>username</td>
<td>admin</td>
</tr>
<tr>
<td>password</td>
<td>changeme</td>
</tr>
</tbody>
</table>
</div>
<fieldset>
<div class="control account-login-textcontrol control-default" data-cid="view197" data-view="views/account/login/TextControl" data-name="username" data-render-time="0">
<span class="uneditable-input " data-role="uneditable-input" style="display:none"></span>
<input type="text" name="username" class=" " value="" autocomplete="off" id="username" placeholder="Username"> </div>
<div class="control account-login-textcontrol control-default" data-cid="view199" data-view="views/account/login/TextControl" data-name="password" data-render-time="0">
<span class="uneditable-input " data-role="uneditable-input" style="display:none"></span>
<input type="password" name="password" class=" " value="" autocomplete="off" id="password" placeholder="Password"> </div><input class="splButton-primary btn" type="submit" value="Sign in">
<input type="hidden" name="cval" value="1900007162">
<input type="hidden" name="return_to" value="/en-US/">
</fieldset>
</form>
Can you, help me? I'm starting with JS.
Related
So I am fairly new to web development and I am making a contact form for my personal website. I made a contact form before and it worked perfectly but I didnt like the way it looked so I made a nicer looking one and now it doesnt work when I click submit the first time but it still clears the form. It only sends an email if the form is empty and the email it sends is empty.
I'm confident my javascript is correct but im not sure why my form is acting this way.
HTML
<form>
<div class="row">
<div class="input-group">
<input type="text" id="name" required>
<label for="name"><i class="fa-solid fa-user"></i> Your Name</label>
</div>
<div class="input-group">
<input type="text" id="phone" required>
<label for="phone"><i class="fas fa-phone-square-alt"></i> Phone No.</label>
</div>
</div>
<div class="input-group">
<input type="email" id="email" required>
<label for="email"><i class="fas fa-envelope"></i> Email Address</label>
</div>
<div class="input-group">
<textarea id="message" rows="8" required></textarea>
<label for="message"><i class="fas fa-comments"></i> Your Message</label>
</div>
<button class="btn btn-primary" type="submit" onclick="sendMail()">Submit <i class="fas fa-paper-plane"></i></button>
</form>
</div>
JS
var params = {
name : document.getElementById("name").value,
phone : document.getElementById("phone").value ,
email : document.getElementById("email").value,
message : document.getElementById("message").value,
}
emailjs.send("service_xnukp8n", "template_mv0tglo", params).then(function (res){
alert("Your form was sent successfully! " + res.status);
})
.catch((err) => console.log(err));
}
Any explanation or tips are appreciated!
Need help on how to use angular with firebase for realtime data,
what i have done
-I have done all installed and imported the firebase sdk
-Configured the environment file with the firebase api
what i want as a result
-I want to post the form input to my forebase realtime storage
-Read and write the input data in my angular app
result im getting
if i submit the form nothing really happens in my browser console and firebase console.
Please im now learning and would be glad for an assistance and correction.
source https://firebase.google.com/docs/database/web/read-and-write
send.component.ts
<form (ngSubmit)="this.authService.wire_Transfer" novalidate>
<div class="authBlock2">
<span style="color: brown;">Enter details for Wire transfer</span>
<div class="formGroup">
<input type="text" class="formControl" matInput placeholder="Enter Recipient Name "
name="recipient" />
</div>
<div class="formGroup">
<input type="text" class="formControl" matInput placeholder="Enter Recipint Bank "
name="bank" />
</div>
<div class="formGroup">
<input type="text" class="formControl" placeholder="Account Number"
name="account" />
</div>
<div class="formGroup">
<input type="text" class="formControl" matInput placeholder="Enter Amount "
name="amount" />
</div>
<div class="formGroup">
<input type="text" class="formControl" placeholder="Enter your PIN"
name="pin" #pin = "ngModel"/> />
</div>
<div class="formGroup">
<button mat-raised-button data-toggle="modal" type="submit" >sen</button>
</div>
</div>
</form>
auth.service.ts
Transfer(userId, name, bank, account, amount,) {
firebase.database().ref('transfer/' + userId).set({
name: name,
bank: bank,
account : account,
amount: amount
});
}
I am using scrapy and I want to post parameters to the following https login form:
<form id="loginForm" name="loginForm" action="/ax/login/loginNN.html" onsubmit="loginWidget.logIn(); loginWidget=null;" onkeypress="checkForReturn(this, event)" method="post">
<input type="hidden" name="referer" value="/ax/web/nn/index.html" />
<input type="hidden" name="encryption" value="1" />
<div class="fakePasswordContainer">
<input class="js-clear_field" tabindex="-1" name="fake_password" type="password">
</div>
<div class="input-group input-group-custom">
<span class="input-group-addon"><span class="icon icon_user"></span></span>
<input type="text" class="form-control lowercase" placeholder="Username" id="input1" name="8d144c359a21a05e83e9a1b56ec6a8e7" type="text" autocomplete="off" >
</div>
<div class="input-group input-group-custom">
<span class="input-group-addon"><span class="icon icon_key"></span></span>
<input id="fakeholder" type="text" class="form-control" placeholder="Password" autocomplete="off" style="display:none;">
<input id="pContent" type="password" class="form-control" placeholder="Password" autocomplete="off">
<input id="pContHidden" name="420d27b4073e303b678e19767daa0f38" type="hidden" autocomplete="off" />
</div>
<div class="row multiple-button-container">
<div class="col-sm-7 align-left">
<p class="btn-inline">Password forgotten?</p>
</div>
<div class="col-sm-5">
<button id="login_btn" type="button" class="btn btn-primary btn-custom btn-block cta" onclick="if (loginWidget != null) return loginWidget.logIn()">Log in</button>
</div>
</div>
</form>
I fail to do so and this is my spider parser:
def parse(self, response):
sel = Selector(response)
login_parameters = sel.xpath("//div/div/div/div/div/div/form[#id='loginForm']/div")
user_param = ""
pass_param = ""
for parameter in login_parameters:
param1 = parameter.xpath('input[#id="input1"]/#name').extract()
if param1:
user_param = param1[0]
param2 = parameter.xpath('input[#id="pContHidden"]/#name').extract()
if param2:
pass_param = param2[0]
form_data = {u'referer':u'/ax/login/startSE.html?cmpi=start-login',u'encryption': u'1',u'fake_password':,user_param:u'123456',,pass_param : u'Abcdefg'}
url = u'https://www.ordnet.se/ax/login/loginNN.html'
print form_data
yield FormRequest(url, callback=self.parse2, formdata=form_data)
Am I missing any parameters in the post or am I doing anything else incorrectly? Any help would be greatly appreciated.
It would be better if you do it with selenium. To prevent fake requests and bots usually there are hidden elements with tokens and CSRF strings which you can't easily fake.
With selenium you can sit in the driver seat and control execution of scripts or can trigger events.
I'm new to angular.js and i have been having trouble getting form input value.
So i have looked for an answer all over including stackoverflow i could not find any answer.
I want to get the input values using the controller but on each attempt i try i get in the console that its undefined on just using either an object or just text
here is the javascript code:
$scope.url = '';
$scope.user = {
password : '',
repassword : ''
};
$scope.registerUser = function()
{
$log.info($scope.email);
$log.info($scope.user);
}
here is the html code:
<table class="table-responsive">
<tbody>
<form class="form-inline" action="" method="post">
<div class="form-group">
<tr>
<td><label for="email">E-mail</label></td>
<td>
<div class="input-group">
<input type="email" class="form-control" name="email" ng-model="email">
<div class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></div>
</div>
</td>
</tr>
</div>
<div class="form-group">
<tr>
<td><label for="password">Password</label></td>
<td><input type="password" class="form-control" name="password" ng-value="user.password"><td>
</tr>
</div>
<div class="form-group">
<tr>
<td><label for="Repassword">Reenter Password:</label></td>
<td><input type="password" class="form-control" name="Repassword" ng-value="user.repassword"></td>
</tr>
</div>
<tr><td><input class="btn btn-default" type="button" value="Register" ng-click="registerUser()"></td></tr>
</form>
</tbody>
</table>
You're using ng-value instead of ng-model:
<input type="password" ng-model="user.password">
<input type="password" ng-model="user.repassword">
You might also want to pass in user to your ng-click for convenience and less typing in the function:
ng-click="registerUser(user)"
$scope.registerUser = function(user) {
console.log(user);
}
I know there are already some threads about accessing an element within another element...I tried a lot of stuff but I can't get it to work...
JSFiddle -> http://jsfiddle.net/YcPc8/2/
What I want to do on the page is to fill out the username and the password - then click the login button.
Here is a part of the html code of the webpage:
<section id="notifications"></section>
<div style="display: block;" id="login" class="">
<div id="login-content">
<form>
<h1>Nessus Vulnerability Scanner</h1>
<input name="login" tabindex="1" placeholder="Username" maxlength="128" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" class="required login-username" type="text">
<i class="glyphicons username"></i>
<input name="password" tabindex="2" placeholder="Password" maxlength="128" autocomplete="off" class="required login-password" type="password">
<i class="glyphicons password"></i>
<div id="remember-me" class="floatleft">
<div class="checkbox login-remember"></div>
<span class="floatleft">Remember Me</span>
</div>
<button type="submit" id="sign-in" tabindex="3" class="button secondary login floatright">Sign In</button>
</form>
<div class="clear"></div>
</div>
</div>
<div class="clear"></div>
<h2>Tenable Network Security</h2>
<div class="clear"></div>
Now I want to fill in the login and the password field...
Here is some of the code I tried within a javascript:
var nessus = window.open("https://localhost:8834/html5.html#/scans");
var doc = nessus.document.getElementById("login-content").getElementsByName("login");
doc.setAttribute("value","USERNAME");
element.getElementsByName("login") returns a list of elements. You might want to write this if you're sure it will return 1 element:
var doc = nessus.document.getElementsByName("login")[0];
EDIT : Moreover, getElementsByName is a method of the Document Interface. You can't use it on node element.
You'd better give an ID to your username input field, and access it directly by
var doc = document.getElementById("usernameInput");
doc.value = "USERNAME";
JSFiddle : http://jsfiddle.net/YcPc8/4/