简体   繁体   中英

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?

您的xpath损坏了: id值缺少开头的撇号:

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

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.

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