Selenium with Java: Struggling with login authentication despite providing accurate credentials

I have been experimenting with creating a login page and encountered an issue even after passing valid credentials using automation code:

Login Failed.

Using Selenium webdriver with Java on Eclipse as the programming language.

I attempted the standard method:

WebElement Login = driver.findElement(By.className("flex-signup"));
Login.click();
WebElement EmailAdd = driver.findElement(By.id("emailAddress")); 

EmailAdd.sendKeys("************");
WebElement Passwd = driver.findElement(By.id("****"));
Passwd.sendKeys("*******");

I also tried an alternative approach using JavaScript driver, but it did not work on the application either.

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].value='*************';" ,****);
jse.executeScript("document.getElementById('****').value='**********';");
WebElement BLogin = driver.findElement(By.className("ladda-label"));
jse.executeScript("arguments[0].click();", BLogin);

Since the application is in JavaScript, I utilized the JavaScript driver as well, but encountered the same outcome.

Answer №1

To improve your code, consider incorporating an explicit wait to ensure that the text is entered into the field only when it is visible. You can try the following revised code:

WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement Login = driver.findElement(By.className("flex-signup"));
Login.click();

WebElement EmailAdd = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("****")));
EmailAdd.sendKeys("************");

WebElement Passwd = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("****")));
Passwd.sendKeys("*******");

Finally, click on the Login button.

Answer №2

Experiment with various browsers such as Firefox, Chrome, and Opera.

  • Use WebDriver firefox=new FirefoxDriver() //for using with Firefox

  • Utilize WebDriver chrome=new ChromeDriver();//for running in Chrome.

Give it a try and observe the results.

Answer №3

What occurs after the Login button is clicked? If the login form takes a moment to load (even just 30 milliseconds can be crucial), it's important to add a wait command! Otherwise, the driver will immediately attempt to input credentials (even if the login form isn't fully loaded yet), resulting in some of the initial characters possibly being lost.

P.S. I am aware that there may be some grammar errors in my writing, please forgive me for those mistakes.

Answer №4

It seems like there might be a missing step in the login procedure.

Typically, the login process involves the following steps:

  1. Locate the ID Box and input Keys
  2. Locate the PW Box and input Keys
  3. Find the Login Button and Click / input "Enter Key" along with PW Keys

Your current method appears as follows:

  1. Click on Login(?)
  2. Locate WebElement EmailAdd
  3. Locate WebElement EmailAdd (x2) (Using different driver call)
  4. Input Keys into EmailAdd
  5. Locate WebElement Passwd
  6. Input Keys into Passwd

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The calculations being performed by class methods are inaccurate

Currently tackling a school project with specific requirements: Create a Temperature class to store temperatures in Fahrenheit, Celsius, and Kelvin. The class should include the following field: ftemp: a double to hold a Fahrenheit temperature. T ...

What is the best way to validate a Class Attribute?

<mat-checkbox _ngcontent-qei-c197="" id="sacSignoffChkbox" class="mat-checkbox mat-accent mat-checkbox-disabled ng-untouched ng-pristine"> The checkbox displayed on the website is currently disabled due to the presence ...

Instructions on how to add an ExternalLink to a webpage linking back to the previous page

I'm in the process of creating an error page for my app, and I'm trying to figure out how to add a Wicket ExternalLink that takes users back to the previous page. I believe I need to store the parameters or entire URL of the last visited page, b ...

Making the most of Java's array expansion

When working in C/C++, the realloc function efficiently allocates additional space for an existing collection. I have seen discussions indicating that its complexity may be sub-linear or even constant. I am curious if there is a similar way to achieve thi ...

Implementing live content updates using setTimeout in Node.js with Express and Jade

Hey there! I'm a beginner with node and I'm interested in having HTML content update dynamically every second. I've managed to update a value using `setTimeout` but I have to refresh the page to see the change. var jade = require('jade ...

Obtaining customer information through a node.js TCP server

I am seeking to retrieve data from a client that is sending information to my server. The following is the code I have written to insert the incoming data into my MySQL database. var net = require('net'); var mysql = require('mysql'); ...

Encountering an Unexpected : Token When Parsing JSON Arrays in AngularJS

I've been searching on various forums for an answer to my AngularJS issue without any luck. I have a simple controller that calls an http service and reads the response data, which is in JSON format with an objects array. However, I'm facing diff ...

Selenium - pausing for scroll completion

I am currently working on automating downloads from a webpage using the selenium tool. My approach involves creating a firefox driver that opens the page and clicks the download button. However, I have encountered an issue where the button needs to be vis ...

Converting a string into a byte array

Is there a way to convert a string into a byte array in the following format: For instance, if I have a string: String str = "0x61"; I would like to get it as: byte[] byteArray = {0x61}; Any suggestions on how this can be achieved? ...

Every time the page is refreshed, the value stored in React localStorage gets

After adding a new item to the list, the local storage gets updated. However, upon page refresh, I noticed that the key remains but the value is reset to an empty array. import { useState, useEffect } from 'react'; function App() { const [data ...

Completely charting the dimensions of an unfamiliar object (and the most effective method for determining its extent)

I am facing a challenge with a "parent" object that contains an unknown number of children at various depths. My main objective is to efficiently map this "parent" object and all its levels of children. How can I achieve this task? Each child already inc ...

Tips for incorporating Apache OpenNLP into a PHP web application

I'm in the process of creating a php web application and I'm interested in incorporating natural language processing tools. I came across the OpenNLP library, but since it's based on Java and I lack experience in that language, I'm unce ...

The focus and blur events for the document in a content editable iframe are not activated by Chrome

As I modify the content of an iframe while it is in focus, I have noticed that this seems to function properly in Firefox. However, I am facing issues as the focus and blur events do not seem to trigger in Google Chrome! var iframe = $('#iframe') ...

Using Jquery to monitor input field modifications following a background ajax refresh

I am facing a challenge with my two JQuery functions. The first function executes an ajax load based on the user's selection from a drop-down menu, and then updates an input field according to the data returned. This function is working correctly. // ...

Angular 2 404 Error persists despite successful retrieval of data from Oracle database using Backend Nodejs URL entered directly into the browser

Recently, I've been working on displaying data in my Angular frontend that is fetched from an Oracle DB connected to my Node backend. When I access the physical API link, the data appears and is displayed in the backend console.log. I'm wonderin ...

Transform all integer values into strings within the JSON dataset

Here is the JSON string provided: {name:"MyNode", width:200, height:100} The goal is to: {name:"MyNode", width:"200", height:"100"} To achieve this, all integer values need to be converted to strings Below is the main code: { "firstName": "John" ...

Fixing an HTML comment in the <title> tag in Next.js: A step-by

When working with Next.js, we encountered the following code snippet on a page: <Head> <title> Some text {title} </title> </Head> During a split second, an HTML comment resembling <!--- ---> appears momentaril ...

Triggering a click event on a radio input type using jQuery

I am having trouble assigning an event to a radio button. Despite searching for solutions online, I haven't been able to find anything that works. The latest solution I attempted involved the following code: $(document).ready(function() { $("#mo ...

Struggling with setting up mustache.js to show data on the website

I'm having some trouble using mustache js to show a list of employee names on a website. I seem to be missing something because when I go to the webpage, nothing shows up. Can someone please help me figure out how to make the employee information appe ...

Encounter an issue during npm installation of electron: "Error verifying the initial certificate."

I recently developed a new app directory and ran the command npm init. However, I encountered an issue while trying to install Electron with the following line of code: npm install electron --save-dev. The error message I received is as follows: > [em ...