Click here to Skip to main content
15,946,663 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I am looking for help in searching for and finding the number in the datagridview on the web page and finding the line number where the number is located.

What I have tried:

C#
driver.Navigate().GoToUrl("my link");
WebDriverWait wait = new WebDriverWait(drv, TimeSpan.FromSeconds(10));
IWebElement gridElement = wait.Until(driver => driver.FindElement(By.Id(val0))); // changed variable name here
IWebElement studentNumberElement = drv.FindElement(By.XPath("//td[contains(text(), 'val0')]"));
IWebElement imageLink = studentNumberElement.FindElement(By.XPath("/html/body/form[2]/div[4]/div[1]/div[4]/div/div/div[2]/div/div["+(i+1)+"]/div/div[2]/h6"));
imageLink.Click();
C#
Posted
Updated 12-Jan-24 6:13am
v2
Comments
Graeme_Grant 12-Jan-24 4:38am    
Not enough information to identify what you are using, the page that you are scraping, and why. We can not see your screen! FWIW, I prefer Playwright.

Your selector looks far too specific. Open the page in a web browser dev tools and have a closer look.

Even poorly designed websites have a structure to them. Are there no other identifiers that you can search for? Like an 'id' or class name(s)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900