How to submit a form in Selenium webdriver if submit button can't be identified?

0 votes
How to submit a form in Selenium webdriver if submit button can't be identified?
Jul 8, 2019 in Selenium by Deepa
6,030 views

2 answers to this question.

0 votes

Hey Deepa, if you want to submit a form on a webpage and submit button can't be identified, then in that case you can use any element of the form to submit it. Selenium webdriver find the form for us from the web element and then you can use that element to submit the form. Below is an example for it:

//Enter username
driver.findElement(By.id("username")).sendKeys("rajan.sharma@gmail.com");

//Enter password
driver.findElement(By.id("password")).sendKeys("password123");

//submit form
driver.findElement(By.id("password")).submit();

/* In this piece of code, id of password input box is used to identify a form. */
answered Jul 8, 2019 by Rajan
0 votes

In addition to flat out submitting the form, in general you can target elements with more complicated paths or without readily available attributes like class and id using the find_element_by_xpath method. 

For example, I was trying to target a button that existed as a child element to an element with a class of "GlobalInviteDialogContent-submitRow". The following works:

send_button = driver.find_element_by_xpath(
    "//div[@class='GlobalInviteDialogContent-submitRow"
    "']/div[1]"
)
send_button.click()

You can find more info here

answered Jul 31 by anonymous
Hi, thank you for your contribution to the Edureka Community.

Register/Sign up on the community to gain points for further contributions. You may ask questions, answer, comment, upvote, and downvote an answer. Each of these would fetch you points and you could be among the top contributors and win exciting merchandise from Edureka.

Cheers!

Related Questions In Selenium

0 votes
1 answer

How to automate radio button and checkbox on a webpage in Selenium Webdriver?

Hey Yashmita, following code snippet automates the ...READ MORE

answered Jul 22, 2019 in Selenium by Anvi
• 14,090 points
823 views
0 votes
3 answers

How to specify "ENTER" button functionality in Selenium WebDriver code?

using OpenQA.Selenium.Interactions; Actions builder = new Actions(driver); ...READ MORE

answered Feb 12, 2019 in Selenium by anonymous
35,936 views
0 votes
1 answer
0 votes
1 answer

How to open a browser window in full screen using Selenium WebDriver with C#

Simply Use this: driver.Manage().Window.Maximize(); READ MORE

answered Jun 7, 2018 in Selenium by Samarpit
• 5,890 points
8,755 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,182 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,383 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,890 points
2,535 views
0 votes
5 answers
0 votes
1 answer