I have a link which is having the href attribute as javascript:void(0), but it is having the onclick function. In the onclick function dev is use to log the number of hits to be database through ajax calls and based on the ajax response they are redirecting to another URL.

The problem is that when I try to on the above said link, it is not redirecting to any other URL and also not trapping any errors for function. So I hope click() executed successfully, but the page was not redirected to another URL. It is stopping me going further.

Any help or suggestions on this is appreciated.

HTML code:

<a href="javascript:void(0);" onclick="get_insert_update_click('http://www.samplewebsite.com/1250290CR','Showcase','1250290CR','CARS_PAGE','CAR_IN_FEATURED_CARS');" id="listing_image_290" name="listing_image_290" class="font_size_15"><img width="155" height="103" src="http://samplewebsite.com/public/uploads/processed/155x103-1409227190127_main_l.jpg" alt=""></a>

Sample Script to click on link:

((JavascriptExecutor) driver).executeScript("window.scrollBy(0,800)");

wait.until(ExpectedConditions.elementToBeClickable(By.id("listing_image_290")));
try {
   driver.findElement(By.id("listing_image_290")).click();                                
} catch(Exception e){
    System.out.println("error");  
    e.printStackTrace();
}



Source link https://sqa.stackexchange.com/questions/13314/click-method-is-not-

LEAVE A REPLY

Please enter your comment!
Please enter your name here