SeleniumBase/examples/translations
Michael Mintz 277ad7cfc4 Allow the use of "conftest.py" for configuring pytest 2021-04-10 12:57:35 -04:00
..
ReadMe.md Update the docs 2020-12-26 21:03:17 -05:00
chinese_test_1.py Update example tests 2021-02-25 02:34:07 -05:00
dutch_test_1.py Update the Dutch example test 2021-01-03 21:38:01 -05:00
english_test_1.py Update example tests 2021-02-25 02:34:07 -05:00
french_test_1.py Update example tests 2021-03-05 17:56:02 -05:00
italian_test_1.py Update the examples 2020-08-08 01:21:28 -04:00
japanese_test_1.py Update translation examples 2020-06-13 01:59:04 -04:00
korean_test_1.py Update example tests 2021-03-09 12:26:40 -05:00
portuguese_test_1.py Update example tests 2021-03-09 12:26:40 -05:00
pytest.ini Allow the use of "conftest.py" for configuring pytest 2021-04-10 12:57:35 -04:00
russian_test_1.py Update the Russian test example 2020-10-22 09:32:23 -04:00
spanish_test_1.py Update translation examples 2020-06-13 01:59:04 -04:00

ReadMe.md

Language Tests (Python 3+)

SeleniumBase supports the following 10 languages: English, Chinese, Dutch, French, Italian, Japanese, Korean, Portuguese, Russian, and Spanish.

Examples can be found in [SeleniumBase/examples/translations].

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)

Translation API

You can use SeleniumBase to selectively translate the method names of any test from one language to another via the console scripts interface. Additionally, the import line at the top of the Python file will change to import the new BaseCase. Example: BaseCase becomes CasoDeTeste when a test is translated into Portuguese.

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)

* Options:
``-n``  (include line Numbers when using the Print action)

* 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 original 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``.)