Answer the question
In order to leave comments, you need to log in
How to click on jquery button using Selenium Webdriver?
Good day! The problem is that you need to log in to the site, but it doesn’t work, the program works without errors, but apparently does not perform the action of clicking on the "Login" button on which the jquery script is located
<input id="UserName" type="text" maxlength = "16" placeholder="Логин" value="" autocomplete="off" />
<input id="Password" type="password" maxlength="6" placeholder="Пароль" autocomplete="off">
<a class="forgot" href="#">Я забыл логин или пароль</a>
<p class="forget-block" style="display:none; margin-top:10px;">
Просто позвоните по бесплатному номеру 8-800-700-787-7
</p>
</div>
<a id="logonButtonId" class="btn" href="#">Войти</a>
//Вход
$('#logonButtonId').click(function (e) {
e.preventDefault();
if (!$(this).hasClass('disabled')) {
if ($('#UserName').val() == '') {
$('#UserName').focus();
$('#UserName').addClass('error');
return false;
}
else if ($('#Password').val() == '') {
$('#Password').focus();
$('#Password').addClass('error');
return false;
} else {
$('#logonButtonId').addClass('disabled');
$('#Password').prop('disabled', 'disabled');
$('#UserName').prop('disabled', 'disabled');
$('#PasswordFromHidden').val($('#Password').val());
$('#UserNameFromHidden').val($('#UserName').val());
if ($('#CaptchaBlockId').length > 0) {
$('#logonBlockId').hide();
$('#CaptchaBlockId').show();
} else {
$('#loginFormId').submit();
}
}
}
});
Answer the question
In order to leave comments, you need to log in
Have you filled out your username/password before?
element.findElement(By.id("logonButtonId")).click();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question