

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to click on sign up button using Java in Selenium I am able to open page but not able to click?
We can click on the Sign up button using Java in Selenium. First of all, we have to identify the Sign up button with the help of any of the locators like id, class name, name, link text, xpath, css or partial link text. After identification, we have to click on the Sign up the button with the help of the method click.
Syntax
WebElement m=driver. findElement(By.id("loc-txt")); m.click();
Example
Code Implementation with click
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; public class SignIn{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://www.linkedin.com/"); // identify element with class name then use click method WebElement m=driver. findElement(By.className("sign-in-form__submit-button")); m.click(); driver.close(); } }
Also, we can click on the Sign up button with the help of the sendKeys method and pass Keys.ENTER as a parameter to that method.
Syntax
WebElement m=driver. findElement(By.id("loc-txt")); m.sendKeys(Keys.ENTER);
Example
Code Implementation with sendKeys
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Keys; public class SignInSendKeys{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://www.linkedin.com/"); // identify element with class name then use sendKeys method WebElement m=driver. findElement(By.className("sign-in-form__submit-button")); m.sendKeys(Keys.ENTER); driver.close(); } }
- Related Questions & Answers
- Despite being rich, why am I not able to get happiness?
- How to click button Selenium Python?
- I have SAP UI5 application that I am not able to start after adding to SAP Fiori Launchpad.
- Using Selenium in Python to click/select a radio button.
- How to click on a link in Selenium?
- How to create right click using selenium?
- How to click on a button with Javascript executor in Selenium with python?
- How to click on a hyper link using linkText in Selenium?
- How to click on a link using Selenium webdriver in Python.
- How to click on hidden element in Selenium WebDriver?
- How to click on image in selenium webdriver Python?
- How to close JFrame on the click of a Button in Java
- How to add Visible On click Button in HTML Code ?
- How to start new Activity on click button in Android?
- How to hide a div in JavaScript on button click?
Advertisements