I am trying to click on SIGN IN link which is placed inside the iframe with class attribute "modalIframe". I have been trying for the past two days to find a solution for this but not able to. Any help would be really appreciated.
Code as below
public class Datereader
{
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","C:\\Users\\Madankumar\\Desktop\\Gecko Driver\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("https://www.redbus.in/");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//div[@class='icon-down icon ich dib']")).click();
driver.findElement(By.id("signInLink")).click();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
WebElement iframeElement=driver.findElement(By.xpath("//*[@class='modalIframe']"));
driver.switchTo().frame(iframeElement);
driver.findElement(By.linkText("sign in")).click();
}
}
On running the code I am getting below error:
JavaScript warning: https://cdn-jp.gsecondscreen.com/static/tac.min.js, line 3: unreachable code after return statement
Use Below code for handling iframe.
While exploring the HTML and trying out different XPATHs to find the element, it is observed that there are
3 elements
present with the same element attributes. so, to made it unique, build the relative XPATH starting fromGooglePlus Signup
element, then find thesign in
link relative to that.try the following code: