I set the Reference but keep getting Object Reference not set error on Trulia page
https://www.trulia.com/NY/Brooklyn/11219/
My Test Step:
on the Search result page select the house with following address
5011 11th Ave
Borough Park, Brooklyn, NY
Screen:
data-testid="search-result-list-container"
class="Box-sc-1f5rw0h-0 kDJgdZ"
Xpath = //*[@id="resultsColumn"]/div[1]/div[2]
My Script:
[FindsBy(How = How.XPath, Using = "//*[@id='resultsColumn']/div[1]/div[2]")]
IWebElement House5011 { get; set; }
public void SearchUsing()
{
foreach (IWebElement SearchResult in House5011.FindElements(By.TagName("div")))
{
if (SearchResult.Text.Contains("5011 11th Ave")&& SearchResult.Text.Equals("Borough Park, Brooklyn, NY"))
{
SearchResult.Click();
Console.WriteLine("Successfully found the address");
}
}
}
question from:
https://stackoverflow.com/questions/65894911/selenium-object-reference-not-set-c-sharp 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…