Joe12
Joe12

Reputation: 69

Not able to click on a button in selenium webdriver

webDriver driver = new FirefoxDriver();
driver.get("https://www.ignitionone.com/company/careers/");
driver.manage().window().maximize();        
Thread.sleep(2000);

driver.findElement(By.xpath("html/body/div[1]/section[1]/div/div/a/button")).submit();

'View positions' button is not clicking with the above code.What is happening in the web page?

Upvotes: 0

Views: 697

Answers (2)

demouser123
demouser123

Reputation: 4264

You see the HTML for this page is

HTML

So, you can use the CSS selector for this as

WebDriver driver = new FirefoxDriver();
driver.get("https://www.ignitionone.com/company/careers/");
driver.manage().window().maximize();        
Thread.sleep(2000);

driver.findElement(By.cssSelector("button.button.teal").click();

And then proceed with doing whatever is necessary. I executed with this in my Python code and it works fine.

Also, you will need to provide the Gecko executable path while calling for the FirefoxDriver()

Upvotes: 2

Stephen Murby
Stephen Murby

Reputation: 1467

The way I have done it before is to use the click handler.

driver.findElement(By.cssSelector(".profile-actions .primary_button > span")).click();

I'm sure you could also select the element by xpath rather than CSS in the above line. It's a similar question to this one.

Upvotes: 0

Related Questions