0 votes
1 view
in Devops and Agile by (25k points)

Can anyone tell me how I can identify and switch to the iframe which has only a title?

<iframe frameborder="0" style="border: 0px none; width: 100%; height: 356px; min-width: 0px; min-height: 0px; overflow: auto;" dojoattachpoint="frame" title="Fill Quote" src="https://tssstrpms501.corp.trelleborg.com:12001/teamworks/process.lsw?zWorkflowState=1&zTaskId=4581&zResetContext=true&coachDebugTrace=none">

I have tried by below code but it is not working

driver.switchTo().frame(driver.findElement(By.tagName("iframe")));

1 Answer

0 votes
by (63.3k points)

You can make use of the CSS Selector or Xpath as shown below:

Approach 1: CSS Selector

driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[title='Fill Quote']")));

Approach 2: Xpath

driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@title='Fill Quote']")));

Check out this link:

https://seleniumatfingertips.wordpress.com/2016/07/05/handling-frames-in-selenium-webdriver-with-java/

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...