Currently, I am extracting data from a webpage and have successfully implemented auto-login functionality. However, I am facing an issue with clicking the "Next" button on the page as it does not have an assigned ID. To locate the correct link, I must utilize XPath. The code snippet below effectively populates the fields.
string functionString = String.Format("document.getElementById('username').value = '{0}';", "usernamehere");
var result = string.Empty;
result = await webView1.InvokeScriptAsync("eval", new string[] { functionString });
The following XPath expression is what I need to identify the "Next" button.
"//a[contains(text(),'Next »')]"
Although I intended to use .Click()
at the end, I am unable to get it to work properly. The syntax seems faulty, causing an HResult error.
String functionString = String.Format("document.evaluate(\"//a[contains(text(),'Next »')].Click();\"");
result = await webView1.InvokeScriptAsync("eval", new string[] { functionString });
Here is the relevant HTML code snippet from the page:
<span>
<a ng-class="{disabled: currentPage == pages_pagination.length-1}" href="" ng-click="nextPage(currentSearch)">Next »</a>
</span>
If you have any insights or suggestions on how I could approach this issue, please share them.