Click on a button is taking a long time

Hi, I am working on Selenium Webdriver for my application and there is a button which I need to click in it. When I use xpath and find the element and issue click on it, it takes more time. I tried keeping explicit wait with conditions but it is not working and moreover, there is no Thread.sleep(secs) before it.

How it can be handled?

Default Asked on November 7, 2015 in Selenium WebDriver.
Add Comment
  • 3 Answer(s)

    Can you please show us some code around the click action?

    Professor Answered on November 8, 2015.

    if(driver.findElements(By.xpath(“//*[@id=’don’]//a[contains(text(),’Body header’)]”)).size() != 0){
    Log.info(“Moved to Body Header tab”);
    driver.findElement(By.xpath(“//*[@id=’dsw’]/table//span//input[@value=’Save and continue’]”)).click();
    Log.info(“Moved to LineItem(s) tab”);
    }else{
    Log.info(“Moved to LineItem(s) tab”);
    }

    driver.findElement(By.xpath(“.//*[@id=’mydiv1′]/table//span//input[@value=’Submit’]”)).click();

    Here Body Header and Line items are two tabs in a page like if we click on body header tab, it shows some fields and shows some other fields if we click on lineitems tab.

    on November 8, 2015.

    Hey Surya,

    Your code seems to be fine, it shouldn’t take much time to click on the link. Is it taking this much amount of time in all browsers?

    Virender

    on November 9, 2015.
    Add Comment

    Hello Surya,

    Try using CSS/ID/Class instead of XPath.

    Shubham

    Train Answered on November 12, 2015.
    Add Comment

    It is working now. Thanks a lot to all

    Default Answered on November 14, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.