Skip to content

Commit 7718076

Browse files
authored
Merge pull request #1907 from emanlove/translation-documentation
Translation documentation
2 parents b0a848d + 8c62b70 commit 7718076

File tree

13 files changed

+87
-85
lines changed

13 files changed

+87
-85
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
matrix:
1212
python-version: [3.8, 3.11] # 3.12, pypy-3.9
1313
rf-version: [5.0.1, 6.1.1, 7.0]
14-
selenium-version: [4.16.0, 4.17.2, 4.18.1, 4.19.0, 4.20.0, 4.21.0]
14+
selenium-version: [4.20.0, 4.21.0]
1515
browser: [firefox, chrome, headlesschrome] #edge
1616

1717
steps:

atest/acceptance/2-event_firing_webdriver/event_firing_webdriver.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ ${event_firing_or_none} ${NONE}
1212
Open Browser To Start Page
1313
[Tags] NoGrid
1414
[Documentation]
15-
... LOG 1:31 DEBUG Wrapping driver to event_firing_webdriver.
16-
... LOG 1:33 INFO Got driver also from SeleniumLibrary.
15+
... LOG 1:30 DEBUG Wrapping driver to event_firing_webdriver.
16+
... LOG 1:32 INFO Got driver also from SeleniumLibrary.
1717
Open Browser ${FRONT_PAGE} ${BROWSER} remote_url=${REMOTE_URL}
1818

1919
Event Firing Webdriver Go To (WebDriver)

atest/acceptance/create_webdriver.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Library Collections
77
Create Webdriver Creates Functioning WebDriver
88
[Documentation]
99
... LOG 1:1 INFO REGEXP: Creating an instance of the \\w+ WebDriver.
10-
... LOG 1:19 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+.
10+
... LOG 1:18 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+.
1111
[Tags] Known Issue Internet Explorer Known Issue Safari
1212
[Setup] Set Driver Variables
1313
Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS}

atest/acceptance/keywords/page_load_timeout.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Test Teardown Close Browser And Reset Page Load Timeout
77
*** Test Cases ***
88
Should Open Browser With Default Page Load Timeout
99
[Documentation] Verify that 'Open Browser' changes the page load timeout.
10-
... LOG 1.1.1:27 DEBUG REGEXP: POST http://localhost:\\d{2,5}/session/[a-f0-9-]+/timeouts {['\\\"]pageLoad['\\\"]: 300000}
11-
... LOG 1.1.1:29 DEBUG STARTS: Remote response: status=200
10+
... LOG 1.1.1:26 DEBUG REGEXP: POST http://localhost:\\d{2,5}/session/[a-f0-9-]+/timeouts {['\\\"]pageLoad['\\\"]: 300000}
11+
... LOG 1.1.1:28 DEBUG STARTS: Remote response: status=200
1212
# Note: previous log check was 33 and 37. Recording to see if something is swtiching back and forth
1313
Open Browser To Start Page
1414

atest/acceptance/multiple_browsers_options.robot

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ Documentation Creating test which would work on all browser is not possible.
99
*** Test Cases ***
1010
Chrome Browser With Selenium Options As String
1111
[Documentation]
12-
... LOG 1:14 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
13-
... LOG 1:14 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
12+
... LOG 1:13 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
13+
... LOG 1:13 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
1414
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
1515
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument("--disable-dev-shm-usage")
1616

1717
Chrome Browser With Selenium Options As String With Attribute As True
1818
[Documentation]
19-
... LOG 1:14 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
20-
... LOG 1:14 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
21-
... LOG 1:14 DEBUG REGEXP: .*['\\\"]--headless=new['\\\"].*
19+
... LOG 1:13 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
20+
... LOG 1:13 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
21+
... LOG 1:13 DEBUG REGEXP: .*['\\\"]--headless=new['\\\"].*
2222
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
2323
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; add_argument ( "--headless=new" )
2424

2525
Chrome Browser With Selenium Options With Complex Object
2626
[Tags] NoGrid
2727
[Documentation]
28-
... LOG 1:14 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
29-
... LOG 1:14 DEBUG REGEXP: .*['\\\"]mobileEmulation['\\\"]: {['\\\"]deviceName['\\\"]: ['\\\"]Galaxy S5['\\\"].*
30-
... LOG 1:14 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
28+
... LOG 1:13 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
29+
... LOG 1:13 DEBUG REGEXP: .*['\\\"]mobileEmulation['\\\"]: {['\\\"]deviceName['\\\"]: ['\\\"]Galaxy S5['\\\"].*
30+
... LOG 1:13 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
3131
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
3232
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; add_experimental_option( "mobileEmulation" , { 'deviceName' : 'Galaxy S5'})
3333

3434
Chrome Browser With Selenium Options Object
3535
[Documentation]
36-
... LOG 2:14 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
37-
... LOG 2:14 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
36+
... LOG 2:13 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
37+
... LOG 2:13 DEBUG REGEXP: .*args['\\\"]: \\\[['\\\"]--disable-dev-shm-usage['\\\"].*
3838
${options} = Get Chrome Options
3939
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
4040
... desired_capabilities=${DESIRED_CAPABILITIES} options=${options}
@@ -47,8 +47,8 @@ Chrome Browser With Selenium Options Invalid Method
4747

4848
Chrome Browser With Selenium Options Argument With Semicolon
4949
[Documentation]
50-
... LOG 1:14 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
51-
... LOG 1:14 DEBUG REGEXP: .*\\\[['\\\"]has;semicolon['\\\"].*
50+
... LOG 1:13 DEBUG REGEXP: .*['\\\"]goog:chromeOptions['\\\"].*
51+
... LOG 1:13 DEBUG REGEXP: .*\\\[['\\\"]has;semicolon['\\\"].*
5252
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
5353
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument("has;semicolon")
5454

atest/acceptance/multiple_browsers_service.robot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Documentation Creating test which would work on all browser is not possible.
99
*** Test Cases ***
1010
Chrome Browser With Chrome Service As String
1111
[Documentation]
12-
... LOG 2:2 DEBUG STARTS: Started executable:
13-
... LOG 2:3 DEBUG GLOB: POST*/session*
12+
... LOG 2:3 DEBUG STARTS: Started executable:
13+
... LOG 2:4 DEBUG GLOB: POST*/session*
1414
${driver_path}= Get Driver Path Chrome
1515
Open Browser ${FRONT PAGE} Chrome remote_url=${REMOTE_URL}
1616
... service=executable_path='${driver_path}'
@@ -24,8 +24,8 @@ Chrome Browser With Chrome Service As String With service_args As List
2424

2525
Firefox Browser With Firefox Service As String
2626
[Documentation]
27-
... LOG 2:2 DEBUG STARTS: Started executable:
28-
... LOG 2:3 DEBUG GLOB: POST*/session*
27+
... LOG 2:3 DEBUG STARTS: Started executable:
28+
... LOG 2:4 DEBUG GLOB: POST*/session*
2929
${driver_path}= Get Driver Path Firefox
3030
Open Browser ${FRONT PAGE} Firefox remote_url=${REMOTE_URL}
3131
... service=executable_path='${driver_path}'

atest/acceptance/open_and_close.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Close Browser Does Nothing When No Browser Is Opened
1616

1717
Browser Open With Not Well-Formed URL Should Close
1818
[Documentation] Verify after incomplete 'Open Browser' browser closes
19-
... LOG 1.1:35 DEBUG STARTS: Opened browser with session id
20-
... LOG 1.1:35 DEBUG REGEXP: .*but failed to open url.*
19+
... LOG 1.1:34 DEBUG STARTS: Opened browser with session id
20+
... LOG 1.1:34 DEBUG REGEXP: .*but failed to open url.*
2121
... LOG 2:2 DEBUG STARTS: DELETE
2222
... LOG 2:5 DEBUG STARTS: Finished Request
2323
Run Keyword And Expect Error * Open Browser bad.url.bad ${BROWSER}

src/SeleniumLibrary/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -550,16 +550,16 @@ class SeleniumLibrary(DynamicCore):
550550
551551
= Language =
552552
553-
SeleniumLibrary offers possibility to translte keyword names and documentation to new language. If language
553+
SeleniumLibrary offers the possibility to translate keyword names and documentation to new language. If language
554554
is defined, SeleniumLibrary will search from
555555
[https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#module-search-path | module search path]
556-
Python packages starting with `robotframework_seleniumlibrary_translation` by using
557-
[https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ | Python pluging API]. Library
556+
for Python packages starting with `robotframework-seleniumlibrary-translation` by using the
557+
[https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ | Python pluging API]. The Library
558558
is using naming convention to find Python plugins.
559559
560-
The package must implement single API call, ``get_language`` without any arguments. Method must return a
560+
The package must implement a single API call, ``get_language`` without any arguments. The method must return a
561561
dictionary containing two keys: ``language`` and ``path``. The language key value defines which language
562-
the package contains. Also value should match (case insentive) the library ``language`` import parameter.
562+
the package contains. Also the value should match (case insensitive) the library ``language`` import parameter.
563563
The path parameter value should be full path to the translation file.
564564
565565
== Translation file ==
@@ -568,8 +568,8 @@ class SeleniumLibrary(DynamicCore):
568568
format. The keys of json are the methods names, not the keyword names, which implements keywords. Value of
569569
key is json object which contains two keys: ``name`` and ``doc``. The ``name`` key contains the keyword
570570
translated name and `doc` contains translated documentation. Providing doc and name are optional, example
571-
translation json file can only provide translations to keyword names or only to documentatin. But it is
572-
always recomended to provide translation to both name and doc. Special key ``__intro__`` is for class level
571+
translation json file can only provide translations to keyword names or only to documentation. But it is
572+
always recommended to provide translation to both name and doc. Special key ``__intro__`` is for class level
573573
documentation and ``__init__`` is for init level documentation. These special values ``name`` can not be
574574
translated, instead ``name`` should be kept the same.
575575
@@ -580,9 +580,10 @@ class SeleniumLibrary(DynamicCore):
580580
languages, it only provides easy way to create full list keywords and their documentation in correct
581581
format. It is also possible to add keywords from library plugins by providing `--plugings` arguments
582582
to command. Example: `rfselib translation --plugings myplugin.SomePlugin /path/to/translation.json` The
583-
genered json file contains `sha256` key, which constains the sha256 sum of the library documentation,
584-
the sha256 sum is used by `rfselib translation --compare /path/to/translation.json` command, which compares
585-
transation to to library and prints outs a table which tell if there are changes needed for translation file.
583+
generated json file contains `sha256` key, which contains the sha256 sum of the library documentation.
584+
The sha256 sum is used by `rfselib translation --compare /path/to/translation.json` command, which compares
585+
the translation to the library and prints outs a table which tells if there are changes needed for
586+
the translation file.
586587
587588
Example project for translation can be found from
588589
[https://github.com/MarketSquare/robotframework-seleniumlibrary-translation-fi | robotframework-seleniumlibrary-translation-fi]

src/SeleniumLibrary/entry/__main__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
1617
import json
1718
from pathlib import Path
1819
from typing import Optional
1920
import click
2021

2122
from .get_versions import get_version
22-
from .translation import compare_translatoin, get_library_translaton
23+
from .translation import compare_translation, get_library_translation
2324

2425

2526
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
@@ -32,10 +33,9 @@ def cli():
3233
"""Robot Framework SeleniumLibrary command line tool.
3334
3435
Possible commands are:
35-
translation
3636
37-
38-
translation will generate detaul tranlsation json file from library keywords.
37+
translation
38+
will generate template translation json file from library keywords.
3939
4040
See each command argument help for more details what (optional) arguments that command supports.
4141
"""
@@ -49,7 +49,7 @@ def cli():
4949
required=True,
5050
)
5151
@click.option(
52-
"--plugings",
52+
"--plugin",
5353
help="Same as plugins argument in the library import.",
5454
default=None,
5555
type=str,
@@ -63,31 +63,31 @@ def cli():
6363
)
6464
def translation(
6565
filename: Path,
66-
plugings: Optional[str] = None,
66+
plugins: Optional[str] = None,
6767
compare: bool = False,
6868
):
6969
"""Default translation file from library keywords.
7070
7171
This will help users to create their own translation as Python plugins. Command
72-
will populate json file with english language. To create proper translation
72+
will populate json file with English language. To create proper translation
7373
file, users needs to translate the keyword name and doc arguments values in
7474
json file.
7575
7676
The filename argument will tell where the default json file is saved.
7777
78-
The --pluging argument is same as plugins argument in the library import.
79-
If you use plugins, it is also get default translation json file also witht
80-
the plugin keyword included in the library.
78+
The --plugin argument will add plugin keywords in addition to the library keywords
79+
into the default translation json file. It is used the same as plugins argument in
80+
the library import.
8181
8282
If the --compare flag is set, then command does not generate template
83-
translation file. Then it compares sha256 sums from the filenane
84-
to ones read from the library documenentation. It will print out a list
85-
of keywords which documentation sha256 does not match. This will ease
86-
translation projects to identify keywords which documentation needs updating.
83+
translation file. Instead it compares sha256 sums from the filename
84+
to the one read from the library documentation. It will print out a list
85+
of keywords for which the documentation sha256 does not match. This will ease
86+
translating projects to identify keywords which needs updating.
8787
"""
88-
translation = get_library_translaton(plugings)
88+
lib_translation = get_library_translation(plugins)
8989
if compare:
90-
if table := compare_translatoin(filename, translation):
90+
if table := compare_translation(filename, lib_translation):
9191
print(
9292
"Found differences between translation and library, see below for details."
9393
)

src/SeleniumLibrary/entry/translation.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
DOC_CHANGED = "Documentation update needed"
2525
NO_LIB_KEYWORD = "Keyword not found from library"
2626
MISSING_TRANSLATION = "Keyword is missing translation"
27-
MISSING_CHECKSUM = "Keyword tranlsaton is missing checksum"
27+
MISSING_CHECKSUM = "Keyword translation is missing checksum"
2828
MAX_REASON_LEN = max(
2929
len(DOC_CHANGED),
3030
len(NO_LIB_KEYWORD),
@@ -33,10 +33,10 @@
3333
)
3434

3535

36-
def get_library_translaton(plugings: Optional[str] = None) -> dict:
36+
def get_library_translation(plugins: Optional[str] = None) -> dict:
3737
from SeleniumLibrary import SeleniumLibrary
3838

39-
selib = SeleniumLibrary(plugins=plugings)
39+
selib = SeleniumLibrary(plugins=plugins)
4040
translation = {}
4141
for function in selib.attributes.values():
4242
translation[function.__name__] = {
@@ -57,18 +57,18 @@ def get_library_translaton(plugings: Optional[str] = None) -> dict:
5757
return translation
5858

5959

60-
def _max_kw_name_lenght(project_tanslation: dict) -> int:
60+
def _max_kw_name_length(project_translation: dict) -> int:
6161
max_lenght = 0
62-
for keyword_data in project_tanslation.values():
62+
for keyword_data in project_translation.values():
6363
if (current_kw_length := len(keyword_data["name"])) > max_lenght:
6464
max_lenght = current_kw_length
6565
return max_lenght
6666

6767

68-
def _get_heading(max_kw_lenght: int) -> List[str]:
68+
def _get_heading(max_kw_length: int) -> List[str]:
6969
heading = f"| {KEYWORD_NAME} "
7070
next_line = f"| {'-' * len(KEYWORD_NAME)}"
71-
if (padding := max_kw_lenght - len(KEYWORD_NAME)) > 0:
71+
if (padding := max_kw_length - len(KEYWORD_NAME)) > 0:
7272
heading = f"{heading}{' ' * padding}"
7373
next_line = f"{next_line}{'-' * padding}"
7474
reason = "Reason"
@@ -89,34 +89,34 @@ def _table_doc_updated(lib_kw: str, max_name_lenght: int, reason: str) -> str:
8989
return f"{line}|"
9090

9191

92-
def compare_translatoin(filename: Path, library_translation: dict):
92+
def compare_translation(filename: Path, library_translation: dict):
9393
with filename.open("r") as file:
9494
project_translation = json.load(file)
95-
max_kw_lenght = _max_kw_name_lenght(library_translation)
95+
max_kw_length = _max_kw_name_length(library_translation)
9696
table_body = []
9797
for lib_kw, lib_kw_data in library_translation.items():
9898
project_kw_data = project_translation.get(lib_kw)
9999
if not project_kw_data:
100100
table_body.append(
101-
_table_doc_updated(lib_kw, max_kw_lenght, MISSING_TRANSLATION)
101+
_table_doc_updated(lib_kw, max_kw_length, MISSING_TRANSLATION)
102102
)
103103
continue
104104
sha256_value = project_kw_data.get("sha256")
105105
if not sha256_value:
106106
table_body.append(
107-
_table_doc_updated(lib_kw, max_kw_lenght, MISSING_CHECKSUM)
107+
_table_doc_updated(lib_kw, max_kw_length, MISSING_CHECKSUM)
108108
)
109109
continue
110110
if project_kw_data["sha256"] != lib_kw_data["sha256"]:
111-
table_body.append(_table_doc_updated(lib_kw, max_kw_lenght, DOC_CHANGED))
111+
table_body.append(_table_doc_updated(lib_kw, max_kw_length, DOC_CHANGED))
112112
for project_kw in project_translation:
113113
if project_kw not in library_translation:
114114
table_body.append(
115-
_table_doc_updated(project_kw, max_kw_lenght, NO_LIB_KEYWORD)
115+
_table_doc_updated(project_kw, max_kw_length, NO_LIB_KEYWORD)
116116
)
117117
if not table_body:
118118
return []
119119

120-
table = _get_heading(max_kw_lenght)
120+
table = _get_heading(max_kw_length)
121121
table.extend(table_body)
122122
return table

0 commit comments

Comments
 (0)