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,320 points
2,764 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,910 points

Related Questions In Selenium

+10 votes
17 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,360 points
198,256 views
0 votes
1 answer
0 votes
2 answers

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

long start = System.currentTimeMillis(); driver.get("Some url"); long finish = ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
8,046 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,460 points
1,053 views
0 votes
2 answers

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,500 points
13,763 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
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,910 points
7,258 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,896 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,910 points
4,659 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,910 points
2,345 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP