|
2 | 2 | # Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
|
3 | 3 | # https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
|
4 | 4 | __author__ = 'Ken Soh <[email protected]>'
|
5 |
| -__version__ = '1.40.0' |
| 5 | +__version__ = '1.41.0' |
6 | 6 |
|
7 | 7 | import subprocess
|
8 | 8 | import os
|
|
37 | 37 | # to track the original directory when init() was called
|
38 | 38 | _tagui_init_directory = ''
|
39 | 39 |
|
| 40 | +# to track file download directory for web browser |
| 41 | +_tagui_download_directory = '' |
| 42 | + |
40 | 43 | # to track location of TagUI (default user home folder)
|
41 | 44 | if platform.system() == 'Windows':
|
42 | 45 | _tagui_location = os.environ['APPDATA']
|
@@ -429,7 +432,7 @@ def setup():
|
429 | 432 | def init(visual_automation = False, chrome_browser = True, headless_mode = False):
|
430 | 433 | """start and connect to tagui process by checking tagui live mode readiness"""
|
431 | 434 |
|
432 |
| - global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome, _tagui_init_directory |
| 435 | + global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome, _tagui_init_directory, _tagui_download_directory |
433 | 436 |
|
434 | 437 | if _tagui_started:
|
435 | 438 | print('[RPA][ERROR] - use close() before using init() again')
|
@@ -564,7 +567,10 @@ def init(visual_automation = False, chrome_browser = True, headless_mode = False
|
564 | 567 | _tagui_id = _tagui_id + 1
|
565 | 568 |
|
566 | 569 | # set variable to track original directory when init() was called
|
567 |
| - _tagui_init_directory = os.getcwd() |
| 570 | + _tagui_init_directory = os.getcwd() |
| 571 | + |
| 572 | + # set variable to track file download directory for web browser |
| 573 | + _tagui_download_directory = os.getcwd() |
568 | 574 |
|
569 | 575 | return True
|
570 | 576 |
|
@@ -1670,3 +1676,26 @@ def clipboard(text_to_put = None):
|
1670 | 1676 |
|
1671 | 1677 | else:
|
1672 | 1678 | return True
|
| 1679 | + |
| 1680 | +def download_location(location = None): |
| 1681 | + global _tagui_download_directory |
| 1682 | + if not _started(): |
| 1683 | + print('[RPA][ERROR] - use init() before using download_location()') |
| 1684 | + return False |
| 1685 | + |
| 1686 | + if location is None: |
| 1687 | + return _tagui_download_directory |
| 1688 | + |
| 1689 | + if "'" in location: |
| 1690 | + print('[RPA][ERROR] - single quote in location not supported here') |
| 1691 | + return False |
| 1692 | + |
| 1693 | + if platform.system() == 'Windows': |
| 1694 | + location = location.replace('/', '\\') |
| 1695 | + |
| 1696 | + if not send("chrome_step('Page.setDownloadBehavior',{behavior: 'allow', downloadPath: '" + location + "'});"): |
| 1697 | + return False |
| 1698 | + |
| 1699 | + else: |
| 1700 | + _tagui_download_directory = location |
| 1701 | + return True |
0 commit comments