QAdam Bednario
QAdam Bednario

Reputation: 5

Issue with clicking link on selenium java

I tried everything. By xpath , by css-selector , by class name too.

//*[@id="opbox-listing"]/div/div/section[2]/section/article[5]/div/div/div[2]/h2/a
thats look xpath , but don't work

on selenium i tried thats way:

        driver.findElement(By.xpath("//*[@id=opbox-listing']/div/div/section[2]/section/article[5]/div/div/div[2]/h2/a")).submit();


        driver.findElement(By.xpath("//*[@id=opbox-listing']/div/div/section[2]/section/article[5]/div/div/div[2]/h2/a")).click();

what i do wrong? someone have any ideas?

Upvotes: 0

Views: 95

Answers (2)

Sameer
Sameer

Reputation: 121

Try out clicking on the element using one of following methods

Method 1:

Actions action = new Actions(driver);
action.moveToElement(<your WebElement>).click().perform();

Method 2:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", <your WebElement>);

These are just workarounds. Please provide the exception that you are getting while performing the normal selenium click operation may be that can help you find an answer.

Upvotes: 0

Ivan Pronin
Ivan Pronin

Reputation: 1916

Your xpath is broken: opening apostrophe is missing for an id value:

"//*[@id='opbox-listing']/div/div/section[2]/section/article[5]/div/div/div[2]/h2/a"

Upvotes: 2

Related Questions