Locating a button not working

Answered

I attempt to locate this button “Place Order” using  XPath and other locating format but it does not work.

COde:
WebElement click = driver.findElement (By.xpath(“/html/body/div[2]/div/div[7]/div/form/section/fieldset[1]/div/div[2]/div/input”));
click.click();

Train Asked on December 2, 2014 in Selenium WebDriver.

Hi
Normally Xpath Start WIth    //

on December 2, 2014.

Here is another code I tried to use…

WebElement PlaceOrderDiv = driver.findElement (By.className(“summary”));
//WebElement checkoutForm = checkoutDiv.findElement(By.tagName(“form”));
WebElement PlaceOrderButton = PlaceOrderDiv.findElement(By.tagName(“input”));
PlaceOrderButton.click();

Nothing happens. No error come up. This make sit more difficult..

on December 2, 2014.
Add Comment
  • 3 Answer(s)
    Best answer

    Hi Ayo,

    Try using submit() rather then click(). As it is a button and sometimes click does not work on buttons. Please close the question if it is resolved.

    Regards,
    Lakshay Sharma

    Professor Answered on December 8, 2014.
    Add Comment

    Hi Jbfannie,

    Try with the following 🙂

    driver.findElement(By.linkText(“Place Order”)).sendKeys(Keys.ENTER);
    Thread.sleep(3000);

    Regards,
    DP Rao

    Default Answered on December 3, 2014.
    Add Comment

    I am writing an example in detail. I hope that solve your problem.

    <html>
    <body>
    <form id=”loginForm”>
    <input name=”username” type=”text” />
    <input name=”password” type=”password” />
    <input name=”continue” type=”submit” value=”Login” />
    <input name=”continue” type=”button” value=”Clear” />
    </form>
    </body>
    <html>

    Locating by Name ==>

    webelement continue = driver.find_element_by_name(‘continue’)
    continue.click

    Default Answered on December 4, 2014.
    Add Comment
  • Your Answer

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