Hi All,



I am unable to click on web link and made xpath like
“//a[contains(text(),'findText')]”
but every time it is clicking on “Company Group” link (there is empty space
in front of the link text)



<li class="sub_menu_title">

<span>

<a class="" href="/admin/company/group/display?selectedMenuItem=3.3">
Company Group </a>

</span>

</li>

<li class="sub_menu_title">

<span>

<a class="hover" href="/admin/company/display?selectedMenuItem=3.4">
Company </a>

</span>

</li>



I tired another way like below, but no use

*public* *void* clickOnSelectedLink(String linkName)
*throws*InterruptedException{



     List<WebElement>
allLinks=browser.findElements(By.*xpath*("//li[span[text()='Agent/Broker
Owner']]/ul/li"));

     *for*(*int* i=0;i<allLinks.size();i++){

       System.*out*.println(allLinks.get(i).getText().trim());

       *if*(allLinks.get(i).getText().trim().equals(linkName)){

             System.*out*.println("we are in if loop");

             //new Actions(browser).click(allLinks.get(i)).build().perform();

             //allLinks.get(i).click();

             allLinks.get(i).sendKeys(Keys.*ENTER*);

             Thread.*sleep*(2000);

             *break*;

       }



     }

Could you please provide me solution for above scenario.



Thanks,

Ram.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAHN3ZY4A7Mb6ACP%3DYmMmaRWxbpWtoR2kge-X4mtMvuj3sGW5-w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Mark Collin at Aug 22, 2013 at 9:40 am
    Your code doesn't match your HTML, what exactly are you trying to do ?

    On 22/08/2013 06:42, Ram Maram wrote:

    Hi All,

    I am unable to click on web link and made xpath like
    “//a[contains(text(),'findText')]” but every time it is clicking on
    “Company Group” link (there is empty space in front of the link text)

    <li class="sub_menu_title">

    <span>

    <a class="" href="/admin/company/group/display?selectedMenuItem=3.3">
    Company Group </a>

    </span>

    </li>

    <li class="sub_menu_title">

    <span>

    <a class="hover" href="/admin/company/display?selectedMenuItem=3.4">
    Company </a>

    </span>

    </li>

    I tired another way like below, but no use

    *public**void*clickOnSelectedLink(String linkName)
    *throws*InterruptedException{

    List<WebElement>
    allLinks=browser.findElements(By./xpath/("//li[span[text()='Agent/Broker
    Owner']]/ul/li"));

    *for*(*int*i=0;i<allLinks.size();i++){

    System./out/.println(allLinks.get(i).getText().trim());

    *if*(allLinks.get(i).getText().trim().equals(linkName)){

    System./out/.println("we are in if loop");

    //new Actions(browser).click(allLinks.get(i)).build().perform();

    //allLinks.get(i).click();

    allLinks.get(i).sendKeys(Keys./ENTER/);

    Thread./sleep/(2000);

    *break*;

    }

    }

    Could you please provide me solution for above scenario.

    Thanks,

    Ram.

    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/selenium-users/CAHN3ZY4A7Mb6ACP%3DYmMmaRWxbpWtoR2kge-X4mtMvuj3sGW5-w%40mail.gmail.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5215DC9A.2080808%40lazeryattack.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedAug 22, '13 at 5:43a
activeAug 22, '13 at 9:40a
posts2
users2
websiteseleniumhq.org

2 users in discussion

Ram Maram: 1 post Mark Collin: 1 post

People

Translate

site design / logo © 2022 Grokbase