diff --git a/src/tagui_header.js b/src/tagui_header.js index 0004b8d4..a792eb8c 100644 --- a/src/tagui_header.js +++ b/src/tagui_header.js @@ -31,6 +31,9 @@ var r_count = 0; var py_count = 0; var sikuli_count = 0; var chrome_id = 0; // chrome context for frame handling and targetid for popup handling var chrome_context = 'document'; var chrome_targetid = ''; +// to track download path if set by user using 'download to location' step +var download_path = ''; + // variables to track frame offset if current context is within a frame var frame_step_offset_x = 0; var frame_step_offset_y = 0; var original_frame_step_offset_x = 0; var original_frame_step_offset_y = 0; @@ -671,6 +674,7 @@ chrome.download = function(url,filename) { // download function for downloading casper.echo('ERROR - for headless and visible Chrome, download file using normal webpage interaction');}; */ chrome.download = function(location) { // download function for setting location of downloaded files +download_path = location; // to store the default download location for subsequent URL visits // below replacement line to set path correctly on Windows to be sent to Chrome browser method if (location.indexOf(':')>0) location = location.replace(/\//g,'\\\\').replace(/\\\\/g,'\\\\'); chrome_step('Page.setDownloadBehavior',{behavior: 'allow', downloadPath: location});} diff --git a/src/tagui_parse.php b/src/tagui_parse.php index dc607574..e3fc7841 100755 --- a/src/tagui_parse.php +++ b/src/tagui_parse.php @@ -693,8 +693,8 @@ function call_py($input_intent) { // helper function to use Python integration f // set of functions to interpret steps into corresponding casperjs code function url_intent($raw_intent) {if (substr(strtolower($raw_intent),0,4)=="www.") $raw_intent = "https://" . $raw_intent; -$twb = $GLOBALS['tagui_web_browser']; $casper_url = $raw_intent; $chrome_call = ''; -if ($twb == 'chrome') {$chrome_call = "var download_path = flow_path; // to set path correctly for Windows\n" . +$twb = $GLOBALS['tagui_web_browser']; $casper_url = $raw_intent; $chrome_call = ''; if ($twb == 'chrome') +{$chrome_call = "if (download_path == '') download_path = flow_path; // below to set path correctly for Windows\n" . "if (download_path.indexOf(':')>0) download_path = download_path.replace(/\//g,'\\\\').replace(/\\\\/g,'\\\\');\n" . "chrome_step('Page.setDownloadBehavior',{behavior: 'allow', downloadPath: download_path});\n"; $casper_url = 'about:blank'; $chrome_call .= "chrome_step('Page.navigate',{url: '".$raw_intent."'}); sleep(1000);\n";}