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 9, 2019 in Selenium by Deepa
18,528 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. */

Check out this Selenium Course to learn more about the Webdriver.

answered Jul 9, 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()

answered Jul 31, 2020 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 23, 2019 in Selenium by Anvi
• 14,150 points
2,352 views
0 votes
6 answers

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

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

answered Feb 13, 2019 in Selenium by anonymous
96,177 views
0 votes
1 answer
0 votes
2 answers

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

Hi , we have inbuilt method Maximize(). driver.Manage().Wind ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
16,033 views
0 votes
2 answers

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,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
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,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
8 answers

How to open a link in new tab of chrome browser using Selenium WebDriver?

This below code works for me in ...READ MORE

answered Dec 14, 2020 in Selenium by Gitika
• 65,770 points
103,024 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP