Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

Selenium: Object Reference not set C#

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...