3" /> 3" /> 3"/>

How should I find element in Selenium WebDriver in Java if there are blank spaces in name and id?

144 Views Asked by At

I have problem with one of the selects on page that I want to locate.

SELECT name="" id="" onblur=""

OPTION selected></OPTION

OPTION value=324686977>324686977</OPTION

OPTION value=324689385>324689385</OPTION

/SELECT

The parent name is "ATTR_SECVOIPNETA" and it generates few more Selects with blank spaces too. I tried few options before asking, however I have no more ideas.

I attached a screen to be more specific how problem looks like.

Screen1

1

There are 1 best solutions below

1
JPNayak On

As per screenshot, this is a part of table and if you can locate label "Numer wirtualny" (in this case), you can also locate the corresponding "select" field(drop down).

Here is a sample xpath for your use-

//*[@id='ATTR_SECVOIPNETA']//descendant::*[contains(text(),'Numer wirtualny')]//following-sibling::select

or

//*[@id='ATTR_SECVOIPNETA']//child::*[contains(text(),'Numer wirtualny')]//following-sibling::select

Note:

  1. Make sure you talk to your developer to add some ids. :)
  2. Descendant is similar to grand grand child. In this case you can use "child".