Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Selenium: Click button under iframe

I have a iframe modal under my site. I am trying to click button in it but I am unable to do so. Below is my code. Please let me know what am i missing

driver.SwitchTo().Frame(driver.FindElement(By.Id("iframeid='frame_name'"))); 
driver.FindElement(By.Id("sendReuqest")).Click();

Expected Result: Button id: sendRequest should get clicked which is on iframe

Actual Result: Element is not found.

Please let me know if you have any questions.

like image 494
user1413 Avatar asked Dec 03 '25 22:12

user1413


1 Answers

Try to do it this way. Let's take frame_name id as iframe_1. Whatever you frame id is you can add instead of iframe_1. Also you have a spelling mistake (typo) it might be sendRequest so I am adding as id of your button.

driver.SwitchTo().Frame(driver.FindElement("iframe_1"))); 
driver.FindElement(By.Id("sendRequest")).Click();

Hope it works. Please do comment and let us know.

Best of luck.