Yes I tried by all the ways. not able to click
Can you please try? Is the link hidden??
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();
}
}
these methods will not work you have to use [b:1lztdgya]Action Class[/b:1lztdgya]
why these methods will not work?
what will action class do as element is not detected through xpath ?
Please elaborate
[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.
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??
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]
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
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();
}
}
*/
}
}