Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute AJAX call with PhantomJSDriver?

My test page contains a link with onclick making an ajax call as follows

 <a title="test delim" alt="" 
onclick="$find('MetricsReport').exportData('TAB');"
 href="javascript:void(0)" 
style="color: rgb(50, 50, 50); . . . ">Click to download</a> 

When the above link is clicked, a report get downloaded to default download location.

I'm testing it with java selenium

 ((JavascriptExecutor) driver).executeScript("$find('MetricsReport').exportData('TAB');"); 

It works fine with ChromeDriver, but doesn't work with PhantomJSDriver . No error is thrown. It kindof executes but nothing happens. The report is not downloaded

How can I make it work with PhantomJSDriver?

like image 489
john Avatar asked Jun 07 '17 03:06

john


1 Answers

Please have a look on this question. This might solve your problem.

How to download a csv file using PhantomJS

You can make AJAX call to download and encode your file, then you can return this content back.

like image 143
Ankur Avatar answered Nov 15 '22 16:11

Ankur