Jump to content
Fórum Script Brasil
  • 0

Não estou conseguindo logar em um site com DOM JS


Question

Pessoal, bom dia!

 

Estou iniciando no JS e quero automatizar algumas ações realizadas por humanos. Uma delas, preciso acessar um site e fazer o download de arquivo, porém, neste site especifico, não estou conseguindo passar da tela de login. Estou testando essa parte  no console do browser mesmo:

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()

Mas quando eu disparo o click, da usuário e senha errada e no console da a seguinte mensagem: 

POST https://siteexemple/en-US/account/login 401 (Unauthorized) common.js:27

Se eu digito o usuário e senha na mão e uso o console apenas para clicar no botão, ele acessa normalmente. Segue abaixo, bloco HTML do 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>

Conseguem me ajudar? Estou iniciando no JS.

Agradeço, desde já!

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      148894
    • Total Posts
      644966
×
×
  • Create New...