I add web element code with picture. How can i press this button with Java. I tried like this;
Thread.sleep(1000);
driver.findElement(By.className("_abm0")).click();
Or
Thread.sleep(1000);
driver.findElement(By.className("._abl-._abm2")).click();
Or
Thread.sleep(1000);
driver.findElement(By.className("_abl- _abm2")).click();
CodePudding user response:
Are these classes unique for only 1 button element in the html page? Or are there others present on the same page?
a. If there is only 1 present, try the following:
driver.findElement(By.xpath("//button[@class='_abl- _abm2']")).click()
b. If there are more than 1 present you can try the following:
driver.findElement(By.xpath("(//button[@class='_abl- _abm2'])[n]")).click()
--> n would be n'th button element --> 1,2...
CodePudding user response:
Try this xpath -
//svg[@aria-label='New post']/parent::div/parent::div
CodePudding user response:
working with;
Thread.sleep(1000); driver.findElement(By.xpath("/html/body/div[1]/div/div/div/div[1]/div/div/div/div[1]/section/nav/div[2]/div/div/div[3]/div/div[3]/div/button")).click();