Link is not getting clicked - Plz refer screenshot | Selenium Forum
M
Posted on 15/06/2016
website: http://in.rediff.com/

scroll down a bit

Screenshot attached for detail

I used all 3 possible ways but getting error no element found ..Please help in resolving

driver.findElement(By.xpath("//*[@id='mw001_widget_img_container']/div[2]/table/tbody/tr[3]/td[1]/a")).click();
driver.findElement(By.cssSelector("div#mw001_widget_img_container > div:nth-child(2) > table > tbody > tr:nth-child(3) > td:nth-child(1) > a"));
driver.findElement(By.linkText("NSE")).click();

M
Replied on 15/06/2016

have you tried making custom xpath?


M
Replied on 16/06/2016

Yes I tried by all the ways. not able to click

Can you please try? Is the link hidden??


M
Replied on 16/06/2016

send the code i'll try running it.


M
Replied on 16/06/2016

package com.qtpselenium.framework.datadriven.SuiteA;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

public class Test5 {

@Test
public void test5(){


System.setProperty("webdriver.chrome.driver","D:\\workspace\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://in.rediff.com");
driver.findElement(By.cssSelector("div#mw001_widget_img_container > div:nth-child(2) > table > tbody > tr:nth-child(3) > td:nth-child(1) > a")).click();
driver.findElement(By.xpath("//*[@id='mw001_widget_img_container']/div[2]/table/tbody/tr[3]/td[1]/a")).click();
driver.findElement(By.linkText("NSE")).click();
}
}


M
Replied on 17/06/2016

these methods will not work you have to use [b:1lztdgya]Action Class[/b:1lztdgya]


M
Replied on 17/06/2016

why these methods will not work?

what will action class do as element is not detected through xpath ?
Please elaborate


M
Replied on 17/06/2016

[quote="Sheenam":1e7b8e89]why these methods will not work?

what will action class do as element is not detected through xpath ?
Please elaborate[/quote:1e7b8e89]
it is able to find the xpath problem is element is not clickable.

action class uses a different mechanism to click.


M
Replied on 17/06/2016

fine . can you please help me in code for action class

Actions action=new Actions(driver);
Webelement link =driver.find...
action.movetoelement(link).click.build.perform.


Should i use this??


M
Replied on 17/06/2016

here is the example

[quote:34151lto]WebElement icon = driver.findElement(By.xpath(" put your xpath here"));
Actions ob = new Actions(driver);
ob.click(icon);
Action action = ob.build();
action.perform();[/quote:34151lto]


M
Replied on 06/08/2016

Not working I tried ..

Can you please try at your end 1st and let me know final 2 line code.

Link:http://in.rediff.com/

want to click on NSE as shown in image


M
Replied on 06/08/2016

The Link is in frame not in main Window.
Please check below the [b:z9nbvnq9]code is working now.[/b:z9nbvnq9]

Hey just answering to some of the doubts in this forum to get in depth knowledge and Hands-On
( I have almost completed training, Ready for interview now)


package module15;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class delete_later {

public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub


WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS); // mandatory the page should load after time

driver.get("http://in.rediff.com");
List<WebElement> frames = driver.findElements(By.tagName("iframe"));
System.out.println("Total Frames"+frames.size());
driver.switchTo().frame(1);
driver.findElement(By.linkText("NSE")).click();
driver.switchTo().defaultContent();

/*
// To get which frame Number
for (int i=0;i<frames.size();i++){
driver.switchTo().frame(i);
try{
if (driver.findElement(By.linkText("NSE")).isDisplayed()) {
System.out.println("The frame number is "+i);
break;
}
} catch (Throwable t){
driver.switchTo().defaultContent();
}

}
*/


}

}


M
Replied on 07/08/2016

Thanks man. Its working..thanks for pasting code