[英]Unable to find the Element on the pop up using Selenium Webdriver with C#
namespace ABC.ABCManager.UIAutomation.Authorization
{
[TestClass]
public class VerifyCreateUsersSendInvite : BaseTest
{
[TestMethod]
public void VerifySendAnInviteLink()
{
Actions actions = new Actions(driver);
selectAndClickOnCustomerName();
Thread.Sleep(3000);
try
{
//Click Send an Invite link
var LinksOnOverview = driver.FindElements(By.CssSelector(".popupFrameLink.summary-tool-link"));
LinksOnOverview[2].Click();
//Verification point to see "Send an Invite" link has opened by checking "TextName" textbox is present or not by using CSS selector
if (IsElementPresent(By.CssSelector("#FirstName")))
{
ExtentManager.verifySafely(driver.FindElement(By.CssSelector("#FirstName")).TagName, "input", "VerifySendAnInviteLink", "link has opened ", driver);
Console.WriteLine("'Send an Invite' link has opened ");
}
}
catch (Exception ex)
{
driver.Close();
}
}
}
}
在上面的代码中,我单击“发送邀请”链接,然后,在该行上得到异常“找不到元素”:
if(IsElementPresent(By.CssSelector(“#FirstName”)))....我正在通过CssSelector检查元素。 我尝试了xpath然后也遇到了同样的异常。 我无法在该弹出窗口中找到其他任何元素(包括名字)。请向我建议解决方案。 提前致谢!!!
可能您应该更改寻找元素的框架
ReadOnlyCollection<string> windowHandles = driver.WindowHandles;
driver.SwitchTo().Window(windowHandles[1]);
// ELEMENTS on Second frame (window)
driver.SwitchTo().Window(windowHandles[0]);
// ELEMENTS on First Frame
try
{
List<IWebElement> frames = new List<IWebElement>(driver.FindElements(By.TagName("iframe")));
driver.SwitchTo().Frame(1);
//Verification point to see "Send an Invite" link has opened by checking Text Name textbox is present or not by using CSS selector
if (IsElementPresent(By.CssSelector("#FirstName")))
{
ExtentManager.verifySafely(driver.FindElement(By.CssSelector("#FirstName")).TagName, "input", "VerifySendAnInviteLink", "link has opened ", driver);
Console.WriteLine("'Send an Invite' link has opened ");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.