How to click on sing up button using java in selenium i am able to open page but not able to click

+1 vote
package TestNG;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.AfterMethod;

import org.testng.annotations.BeforeMethod;

import org.testng.annotations.Test;

public class Basic {

WebDriver driver;

@BeforeMethod

public void setup() {

System.setProperty("webdriver.chrome.driver","D:\\selenium\\chromedriver.exe");

driver = new ChromeDriver();

driver.manage().window().maximize();

driver.get("https://www.instagram.com/");

}

@AfterMethod

public void after() {

driver.quit();

}

@Test

public void  demo() throws InterruptedException {

Thread.sleep(6000);

WebElement clickOnsingButton=driver.findElement(By.xpath("//body/div[@id='react-root']/section/main/article/div/div/p/a[1]"));

clickOnsingButton.click();

Thread.sleep(6000);

}

}
Sep 17, 2020 in Selenium by anonymous
• 410 points
2,647 views

2 answers to this question.

0 votes
Best answer

For a software testing services company while automating the application we avoid the usage of the Xpaths. We give preferences to the Classname>=Id>=Linktext>=Css and then last preference is given to the Xpath. Please try the code below.

public void clickCancelBtn() {    
webElement = driver.findElement(By.cssselector("button.btn.btn-outline-primary.bold"));
webElement.click(); 
}

Also, Form seems to be written using jquery. We have to look into the other solution if it not working at your end. Please do share your code snippet or error that it throws if it is not working at your end.

answered Sep 17, 2020 by Vishal

selected Sep 17, 2020 by Jordan
Thank you it work for me
Glad to help!
0 votes

If you know for sure that the element is present, you could try this to simulate the click - if.Click() isn't working

driver.findElement(By.name("submit")).sendKeys(Keys.RETURN);

or

driver.findElement(By.name("submit")).sendKeys(Keys.ENTER);
answered Sep 17, 2020 by Jean

Related Questions In Selenium

0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,869 views
+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13, 2020 in Selenium by Karan
• 19,610 points
8,286 views
0 votes
1 answer

I am not able to generate extent report with screenshot in selenium cucumber java .. Please help me out

Hello @kanikahans, You need to define Extent Report ...READ MORE

answered Aug 24, 2020 in Selenium by Niroj
• 82,880 points
8,445 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,567 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,084 views
0 votes
2 answers

What is the role of TestNG & JUnit frameworks in Selenium?

TestNG and JUnit are test frameworks . it ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,845 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,178 views
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