I am trying to extract specific text using a CSS selector. Here's a screenshot of the part that I would like to extract
I tried
div[id="Section3"]:first-child
but this doesn't return anything. I can't depend on locating the element by the text because I need to extract that text as shown.
This is the relevant HTML
<div class="ad24123fa4-c17c-4dc5-9aa5-ea007a8db30e-5" style="top:8px;left:218px;width:124px;height:31px;text-align:center;">
<table width="113px" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center">
<span class="fcb900b29f-64d7-453d-babf-192e86f17d6f-7">نظامي</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
The full HTML is here.
This is my try
On Error Resume Next
Set ele = .FindElementByXPath("//span[text()='ãäÇÒá']")
If ele Is Nothing Then sStatus = "äÙÇãí" Else sStatus = "ãäÇÒá"
On Error GoTo 0
While inspecting the element I noticed that there is a hint of using $0 in the console .. Can this be useful?
As for the two possible texts "نظامي" and "منازل"
To use xpath with multiple possible search values use the following syntax:
CSS selectors (that work for me):
which is an abbreviation of the full selector:
You can also index into table nodeList
Otherwise:
Reading in from html file I can take the last index of the matches based on class selector. For selenium you would switch to:
VBA: