I am using Selenium to test a vb.net site but when I click the btnNoMatch the pages changes and for some reason, it appears that Selenium doesn't update the source code as I get the below error.
The Error
An unhandled exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll
Additional information: Unable to locate element: #chkTermsAccept
I have tried using sleep, refresh and navigate but no luck. If I avoid the btnNoMatch click and navigate directly to the page then it is able to find the elements on the page but I cant do this as information is meant to be populated into text boxes after the btnNoMatch is clicked.
The Code
driver.Navigate().GoToUrl("http://Mysite.development.ie/")
Dim element As IWebElement = driver.FindElement(By.Id("LoginUsername"))
element.SendKeys("UserName")
Dim element1 As IWebElement = driver.FindElement(By.Id("LoginPassword"))
element1.SendKeys("Password")
Dim element2 As IWebElement = driver.FindElement(By.Id("LoginBtn"))
element2.Click()
System.Threading.Thread.Sleep(5000)
Dim element3 As IWebElement = driver.FindElement(By.Id("CustomerId"))
element3.SendKeys("1")
'Wait Time
System.Threading.Thread.Sleep(7000)
Dim element4 As IWebElement = driver.FindElement(By.CssSelector(".ClickCustomer"))
element4.Click()
Dim element5 As IWebElement = driver.FindElement(By.Id("cbxNoMobileNo"))
element5.Click()
Dim element6 As IWebElement = driver.FindElement(By.Id("btnNoNumberConfirm"))
element6.Click()
driver.FindElement(By.Id("btnNoMatch"))
element9.Click()
'System.Threading.Thread.Sleep(4000)
'driver.Navigate().Refresh()
'driver.Url = "http://Mysite.development.ie/Customer/1"
'System.Threading.Thread.Sleep(4000)
'driver.Manage().Window.Maximize()
''Dim wait As WebDriverWait = New WebDriverWait(driver, 4000)
'wait.Until(ExpectedConditions.visibilityOfElementLocated((By.Id("id"))))
Dim element10 As IWebElement = driver.FindElement(By.Id("chkTermsAccept"))
element10.Click()
Dim element12 As IWebElement = driver.FindElement(By.Name("txtName"))
element12.SendKeys("John")
System.Threading.Thread.Sleep(14000)
driver.Dispose()
Thanks for any help with this issue.