Igor Fernando
Igor Fernando

Reputation: 1

I can't find the Web Element oh the page

I'm trying to find the web element "Grupo de Parâmetros" but when I use selenium IDE to locate the xpath:idRelative //div[@id='menu']/ul/li[6]/ul/li[4]/ul/li/ul/li[2]/a/span or xpath:postion //li[6]/ul/li[4]/ul/li/ul/li[2]/a/span does not occur anything . I'm using eclipse/java.

This is the code of page

<li class="ui-menuitem ui-widget ui-corner-all ui-menuitem-active" role="menuitem">
    <a class="ui-menuitem-link ui-corner-all ui-state-hover" onclick="PrimeFaces.ab({source:'menu',global:false,params: [{name:'menu_menuid',value:'5_3_0_1'}],formId:'j_idt8'});return false;" href="#" title="" tabindex="-1">
        <span class="ui-menuitem-text">**Grupo de Par&#xE2;metros**</span>
    </a>
</li>

And this is my automatized test

driver.get(...);

driver.findElement(By.xpath("//div[@id='menu']/ul/li[6]/ul/li[4]/ul/li/ul/li[2]/a/span")); 

    driver.findElement(By.id("paramGroupAlias")).clear();
    driver.findElement(By.id("paramGroupAlias")).sendKeys("box");

    driver.findElement(By.id("pesquisar")).click();

    WebElement retorno = driver.findElement(By.id("j_idt64_data"));
    System.out.println(" Retorno "+ retorno.getText() );

Upvotes: 0

Views: 103

Answers (1)

Francisco Romero
Francisco Romero

Reputation: 13199

I also tried this but I also couldn't make it from Selenium IDE when I exported it so I programmed it in my Java proyect with JQuery. I think it will be good for you something like this:

#ui-menuitem ui-widget ui-corner-all ui-menuitem-active > a > span 

Where you reference the class of the first element of your page and you descend "levels" in the page.

But I also made reference to the object that I wanted to refer to like this:

#ui-menuitem-text

I used it in my Java project and it worked but I tried this with 3 'divs' one inside the others. Anyway, I think it will work to you.

Please let me know if it works.

Upvotes: 1

Related Questions