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.
WebElement iframe = driver.findElement(By.tagName("iframe"));
driver.switchTo().frame(iframe); //Move inside to the frame.
WebElement body = driver.findElement(By.tagName("body"));
body.click();
driver.findElement(By.linkText("sign in")).click();
driver.switchTo().defaultContent(); //Move outside to the frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With