Skip to content

Add the SeleniumBase Universal Translator API #565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
May 11, 2020
Merged

Conversation

mdmintz
Copy link
Member

@mdmintz mdmintz commented May 11, 2020

Add the SeleniumBase Universal Translator API

SeleniumBase supports the following 10 languages:

  • English
  • Chinese / 中文
  • Dutch / Nederlands
  • French / Français
  • Italian / Italiano
  • Japanese / 日本語
  • Korean / 한국어
  • Portuguese / Português
  • Russian / Русский
  • Spanish / Español

Multi-language tests are run with pytest like any other test. Every test method has a one-to-one mapping to every other supported language. Example:
self.open(URL) = self.开启网址(URL)

You can use SeleniumBase to translate any test from one language to another by using the console scripts interface:

seleniumbase translate
* Usage:
seleniumbase translate [SB_FILE].py [LANGUAGE] [ACTION]

* Languages:
``--en`` / ``--English``  |  ``--zh`` / ``--Chinese``
``--nl`` / ``--Dutch``    |  ``--fr`` / ``--French``
``--it`` / ``--Italian``  |  ``--ja`` / ``--Japanese``
``--ko`` / ``--Korean``   |  ``--pt`` / ``--Portuguese``
``--ru`` / ``--Russian``  |  ``--es`` / ``--Spanish``

* Actions:
``-p`` / ``--print``  (Print translation output to the screen)
``-o`` / ``--overwrite``  (Overwrite the file being translated)
``-c`` / ``--copy``  (Copy the translation to a new ``.py`` file)

* Examples:
Translate test_1.py into Chinese and only print the output:
>>> seleniumbase translate test_1.py --zh  -p
Translate test_2.py into Portuguese and overwrite the file:
>>> seleniumbase translate test_2.py --pt  -o
Translate test_3.py into Dutch and make a copy of the file:
>>> seleniumbase translate test_3.py --nl  -c

* Output:
Translates a SeleniumBase Python file into the language
specified. Method calls and ``import`` lines get swapped.
Both a language and an action must be specified.
The ``-p`` action can be paired with one other action.
When running with ``-c`` (or ``--copy``) the new file name
will be the orginal name appended with an underscore
plus the 2-letter language code of the new language.
(Example: Translating ``test_1.py`` into Japanese with
``-c`` will create a new file called ``test_1_ja.py``.)

Also included in this Release are the following updates/changes:

  • Allow multithreaded browser sessions to be reused when specified
  • Update the pytest dependency version to 5.4.2
  • Improve error-handling when using headless mode on Linux
  • Add methods for controlling Local Storage and Session Storage:
self.set_local_storage_item(key, value)
self.get_local_storage_item(key)
self.remove_local_storage_item(key)
self.clear_local_storage()
self.get_local_storage_keys()
self.get_local_storage_items()
self.set_session_storage_item(key, value)
self.get_session_storage_item(key)
self.remove_session_storage_item(key)
self.clear_session_storage()
self.get_session_storage_keys()
self.get_session_storage_items()

@mdmintz mdmintz merged commit 0c68192 into master May 11, 2020
@mdmintz mdmintz deleted the add-the-translator branch May 11, 2020 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant