Module15 - FrameSelection - Unable to apply concept to PayTM | Selenium Forum
M
Posted on 10/01/2016
Working with Module15 - Frame Selection.

Tried logging into Paytm webpage but I'm not able to switch to login frame. Tried using switchto function but the login frame is not getting recognized. Used the below code for entering the username and password. Can you please help me here. Thanks!!

WebDriver driver = new FirefoxDriver();
driver.get("http://www.paytm.com");

driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

List<WebElement> frames = driver.findElements(By.tagName("iframe"));
System.out.println("Number of frames: "+frames.size());

for(int i=0;i<frames.size();i++)
{
driver.switchTo().frame(i);
if(driver.findElements(By.xpath("//input[@name='username']")).size() == 0)
{
System.out.println("Didn't find the element in frame :"+i);
driver.switchTo().defaultContent();

}
else
{
System.out.println(i);
driver.switchTo().defaultContent();
}
}
System.out.println("Switching to the relevant frame");
driver.findElement(By.className("login")).click();
//driver.switchTo().frame(1);

driver.findElement(By.xpath("//input[@name='username']")).sendKeys("+91213212312");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.close();

M
Replied on 11/01/2016

use this code


[quote:2qs8qzca] driver.switchTo().frame(
driver.findElement(By
.xpath("//iframe[@ng-hide='showVerificationScreen']")));
Thread.sleep(10000);//you can use other waits
System.out.println("Switching to the relevant frame");

driver.findElement(By.xpath("//input[@id='input_0']")).sendKeys("+91213212312");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.close();[/quote:2qs8qzca]