【发布时间】:2013-10-21 14:28:23
【问题描述】:
html代码:
<iframe title="javascript:''" src="PageName.aspx" _events="[object Object]">
<htlml>
<head>
<body>
<form name="FormName">
<div>
<span>
<input name="ButtonName>
我的问题:如何找到名称为“ButtonName”的元素? 我当前的 C# 代码
//To find the iframe
IWebElement Object = driver.FindElement(By.XPath("XPath to the iframe"); //works
//To switch to and set focus to the iframe
driver.SwitchTo().Frame(Object); //works
//To find element with name "ButtonName"
IWebElement Button = driver.FindElement(By.Name("ButtonName")); //error: cannot find the element
感谢任何帮助。
【问题讨论】:
-
我猜这个问题是关于Selenium的,应该添加到标签和问题中。
-
只有“Oject”和“Object”拼写错误才有问题吗?
-
您好 user1177636,感谢您的评论。可能是帧切换失败的情况。我该如何验证呢?怎样才能让切换成功?