Unable to click the link using selenium webdriver | Selenium Forum
M
Posted on 25/09/2016
Hi all,

I have written the below Junit code to click on the [b:qlnjnrm2]"Sign In"[/b:qlnjnrm2] link present on the [b:qlnjnrm2]quikr [/b:qlnjnrm2]website [b:qlnjnrm2]http://www.quikr.com/[/b:qlnjnrm2].

The code runs fine without any errors but the webdriver doesn't seems to be clicking the [b:qlnjnrm2]"Sign In"[/b:qlnjnrm2] link on the website. Please suggest.

[b:qlnjnrm2]I'm using:[/b:qlnjnrm2]
[b:qlnjnrm2]OS:[/b:qlnjnrm2] Win10
[b:qlnjnrm2]Slenium WebDriver:[/b:qlnjnrm2] Version 3.0.0.beta3
[b:qlnjnrm2]Firefox browser version:[/b:qlnjnrm2] 49.0.1

[code:qlnjnrm2]import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Quikr {
@Test
public void loginTest(){
System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.quikr.com/");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
if(!driver.findElements(By.xpath(".//*[@id='responsiveHeader']/div[1]/div[1]/ul/li[4]/a/span[1]")).isEmpty()){
System.out.println("Link present");
}else{
System.out.println("Link not present");
}
driver.findElement(By.xpath(".//*[@id='responsiveHeader']/div[1]/div[1]/ul/li[4]/a/span[1]")).click();
}
}[/code:qlnjnrm2]

M
Replied on 26/09/2016

[quote:36klyx0g] if(!driver.findElements(By.xpath(".//*[@id='responsiveHeader']/div[1]/div[1]/ul/li[4]/a/span[1]")).isEmpty()){
System.out.println("Link present");
}else{
System.out.println("Link not present");
}
driver.findElement(By.xpath(".//*[@id='responsiveHeader']/div[1]/div[1]/ul/li[4]/a/span[1]")).click();
} [/quote:36klyx0g]

what are you trying to do? just click on the sign in button.


M
Replied on 27/09/2016

I want to click on the Sign In link and providing the username and password.

But I'm unable to click on the 'Sign In' link please suggest.


M
Replied on 28/09/2016

send a screen shot of where you want to click and also the line of selenium code you have tried.


M
Replied on 28/09/2016

I have used the below line of code to click on the [b:59slueym]'Sign In'[/b:59slueym] link as highlighted in the screen shot attached.

[b:59slueym][u:59slueym]URL:[/u:59slueym][/b:59slueym] http://www.quikr.com/

[code:59slueym]driver.findElement(By.xpath(".//*[@id='responsiveHeader']/div[1]/div[1]/ul/li[4]/a/span[1]")).click();[/code:59slueym]


M
Replied on 28/09/2016

use this code. this is working.

[code:26el0fwx]WebDriver driver = new FirefoxDriver();
driver.get("http://www.quikr.com/");
driver.findElement(
By.xpath("//*[@id='responsiveHeader']/div[1]/div[1]/ul/li[4]/a/span[@class='sign-in']"))
.click();
[/code:26el0fwx]


M
Replied on 29/09/2016

Its not working for me. Whats the FireFox Browser version and Selenium version you are using?

[b:1fypoi6q]I'm using [/b:1fypoi6q]
Firefox Version: 49.01
Selenium: 3.0.0-beta3


M
Replied on 29/09/2016

use selenium 2.53 and firefox 40-43