Selenium WebDriver: naukri.com login fails every time

0 votes

I am trying to create a script to update my naukri profile.

But I am facing issue with the login part as naukri.com has 2 pages for the same login window and out of those the pages, a random page is displayed. Below are the codes I used:

Email ID / Username

<input type="text" id="usernameField" placeholder="Enter your Email ID or Username" rel="required:usernameField_required|blur" autocapitalize="none" value="">

Password

<input type="password" id="passwordField" placeholder="Enter your Password" rel="required:passwordField_required|blur" autocapitalize="none" value="">

https://login.naukri.com/nLogin/Login.php Email ID:

<input type="text" name="USERNAME" id="emailTxt" placeholder="Enter Email ID" rel="regEmail" ref="emailRad" autocomplete="off" maxlength="100" class="       err">

Password:

<input type="password" name="PASSWORD" id="pwd1" placeholder="Enter password" rel="logPass" maxlength="40" class="     err">
Jul 24, 2018 in Selenium by Martin
• 4,220 points
444 views

1 answer to this question.

0 votes

Use the following code after driver.get(URL),

String URL1="https://www.naukri.com/nlogin/login";

String URL2="https://login.naukri.com/nLogin/Login.php";

String URL=driver.getCurrentUrl();

if(URL.equals(URL1)){

    driver.findElement(By.id("usernameField")).sendKeys("Username");

    driver.findElement(By.id("passwordField")).sendKeys("password");

    } else if(URL.equals(URL2)) {

    driver.findElement(By.name("USERNAME")).sendKeys("Username");

    driver.findElement(By.name("PASSWORD")).sendKeys("password");

    }
answered Jul 24, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

+9 votes
15 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,270 points
70,973 views
0 votes
1 answer
0 votes
1 answer

How to know the exact time to load a page using Selenium WebDriver?

Normally WebDriver should return control to your ...READ MORE

answered Aug 23, 2018 in Selenium by Meci Matt
• 9,420 points
1,431 views
0 votes
1 answer

Login popup window using selenium webdriver?

Follow this steps: 1) Open the FireFox browser 2) ...READ MORE

answered Aug 23, 2018 in Selenium by Meci Matt
• 9,420 points
97 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
977 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,136 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
875 views
0 votes
1 answer

Selenium WebDriver Real Time Projects

You should start with basics projects website ...READ MORE

answered Apr 30, 2018 in Selenium by Samarpit
• 5,130 points
1,937 views
0 votes
1 answer

Not able to login using selenium webdriver using Java Language

Try to send text to the username ...READ MORE

answered Jul 17, 2018 in Selenium by Samarpit
• 5,130 points
364 views