-3

I'm using C#, and I can't get the the settlementdate in a textbox from nested tables. Can you please help me?

I've tried the following:-

driver.FindElement(By.Id("settlementdate"))
driver.FindElement(By.Name("settlementdate"));
driver.FindElement(By.Name("//*[@id='settlementdate']");
driver.FindElement(By.Name("//input[@id='settlementdate']");

See below for the html code on the website

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Your question is getting downvoted for a few reasons -- mainly, the screenshot of HTML. This is very difficult to read (small text, straining eyes), and even more difficult to debug, because there is no HTML text which we can test against. You also just said you "can't get the settlementdate in a textbox". What does that mean? Is an exception getting thrown? What prints out onto the console? Does nothing happen at all? Adding these details will help improve the quality of this question, and you will get better answers. I would like to answer this, but cannot proceed without these details. – CEH Nov 28 '19 at 16:21

3 Answers3

0

try driver.FindElement(By.Xpath("//table/tr/td/input[@id='settlementdate']");

Sooraj
  • 565
  • 3
  • 8
0

To locate the desired element so you have to induce WebDriverWait for the desired ElementToBeClickable() and you can use either of the following Locator Strategies:

  • CssSelector:

    IWebElement element = new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("table#headtable tr td input#settlementdate[name='settlementdate']")));
    
  • XPath:

    IWebElement element = new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//table[@id='headtable']//tr//td//input[@id='settlementdate' and @name='settlementdate']")));
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Thank you for your help. I've managed to fix the issue.

The inputbox was in a frame, and I used driver.SwitchTo().Frame() to switch to the frame.