简体   繁体   中英

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?

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()

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM