1

im trying to identify when an element has the text field empty, I just tried with some codes but the problem right here is there is not an empty space, it has white spaces inside, and I don't know how to validate if this exist to jump to the other class.

Im trying this without success.

This is the site elements part.

<div class="detalle-producto__descripcion">
                            <p>
                                 
                            </p>
                        </div>

And this is my code:

If driver.FindElementByXPath("//*[@id='headerAngular']/div[52]/main/div/div[1]/div[2]/div[2]/p").Text <> " " Then
QHarr
  • 83,427
  • 12
  • 54
  • 101
Peter
  • 33
  • 5
  • with xpath you can collapse that spacing. Also, can you share the url and explain what you want? You want to ignore nodes with no text in (i.e. something other than whitespace)? – QHarr Mar 05 '21 at 19:53
  • Here is a link with a product without description ( https://www.tecnoglobal.cl/tiendaonline/webapp/detalle/apc-smart-ups-srt-5000va-230v---------------------/947 ) and this one has description ( https://www.tecnoglobal.cl/tiendaonline/webapp/detalle/desktop-m720q-tiny-i5-9400t-8gb-256gb-m-2-3anos/14831 ) so I just want check if the description field is empty or not but in this case is not empty, it has white spaces and I want to know how to identify when it has white spaces. – Peter Mar 05 '21 at 20:02
  • Does the following not work? `driver.FindElementByCss('.detalle-producto__descripcion').text = vbNullString` – QHarr Mar 05 '21 at 20:08
  • Wow, works!, so just for learn to the future, exists an counterpart of vbnullstring ? because vbNullstring is like "string null", thanks you very much QHarr you always help me to learn a lot of selenium vba – Peter Mar 05 '21 at 20:20
  • See reference I added to answer for reading. – QHarr Mar 05 '21 at 20:20

1 Answers1

1

You want to test against vbNullString (a null string) not against a space. That whitespace is actually stripped via parser). For one thing, that is faster than "" (empty string literal) comparison.

driver.FindElementByCss('.detalle-producto__descripcion').text = vbNullString

Addit info:

Is there any difference between vbNullString and ""?

QHarr
  • 83,427
  • 12
  • 54
  • 101