[英]FindsBy from SeleniumExtras can't find IWebElement
I've updated packages from my project on Mac and find out that PageObjects has been moved to SeleniumExtras. 我已经从Mac上的项目中更新了软件包,并发现PageObjects已移至SeleniumExtras。 I struggle to use it but the error "System.NullReferenceException : Object reference not set to an instance of an object." 我很难使用它,但是出现错误“ System.NullReferenceException:对象引用未设置为对象的实例”。 is shown. 显示。 Nevertheless, the same element can be found through FindElement. 但是,可以通过FindElement找到相同的元素。 Currently, I run out of ideas and would appreciate the help. 目前,我没有任何想法,希望能提供帮助。 Thanks! 谢谢!
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using NUnit.Compatibility;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using SeleniumExtras.PageObjects;
namespace SomeTest
{
[TestFixture]
public class UnitTest1
{
[FindsBy(How = How.XPath, Using = "//*[@id='lst-ib']")]
public IWebElement _searchField;
public IWebDriver chrome;
[SetUp]
public void TestMethod1()
{
chrome = new ChromeDriver(@"/Volumes/Macintosh HD/QA/SomeTest/SomeTest/bin/Debug/netcoreapp2.1");
}
[Test]
public void SomeTest()
{
chrome.Navigate().GoToUrl("https://www.google.com/");
_searchField.SendKeys("Some Text");
}
[TearDown]
public void CloseBrowser()
{
chrome.Close();
}
}
}
Got solution: 得到的解决方案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.