Repository: robotframework/SeleniumLibrary (language: python)

Issue:
Add missing methods to stub file
Add missing methods to stub file


Discussion / hints:

Fix patch:
diff --git a/gen_stub.py b/gen_stub.py
index 106f6fffa..7ae5ffb01 100644
--- a/gen_stub.py
+++ b/gen_stub.py
@@ -106,19 +106,33 @@ def keyword_line(keyword_arguments, keyword_types, method_name):
 from datetime import timedelta
 from typing import Any, Optional, Union
 
+from selenium.webdriver.remote.webdriver import WebDriver
+from selenium.webdriver.remote.webelement import WebElement
 
 class SeleniumLibrary:
 """
 pyi_boilerplate_append = """
     def add_library_components(self, library_components): ...
     def get_keyword_names(self): ...
-    def run_keyword(self, name, args, kwargs=None): ...
-    def get_keyword_arguments(self, name): ...
-    def get_keyword_tags(self, name): ...
-    def get_keyword_documentation(self, name): ...
-    def get_keyword_types(self, name): ...
-    def get_keyword_source(self, keyword_name): ...
-
+    def run_keyword(self, name: str, args: tuple, kwargs: Optional[dict] = None): ...
+    def get_keyword_arguments(self, name: str): ...
+    def get_keyword_tags(self, name: str): ...
+    def get_keyword_documentation(self, name: str): ...
+    def get_keyword_types(self, name: str): ...
+    def get_keyword_source(self, keyword_name: str): ...
+    def failure_occurred(self): ...
+    def register_driver(self, driver: WebDriver, alias: str): ...
+    @property
+    def driver(self) -> WebDriver: ...
+    def find_element(self, locator: str, parent: Optional[WebElement] = None): ...
+    def find_elements(self, locator: str, parent: WebElement = None): ...
+    def _parse_plugins(self, plugins: Any): ...
+    def _parse_plugin_doc(self): ...
+    def _get_intro_documentation(self): ...
+    def _parse_listener(self, event_firing_webdriver: Any): ...
+    def _string_to_modules(self, modules: Any): ...
+    def _store_plugin_keywords(self, plugin): ...
+    def _resolve_screenshot_root_directory(self): ...
 """
 
 INIT_METHOD = KeywordBuilder.build(SL.__init__)
@@ -130,5 +144,5 @@ def get_keyword_source(self, keyword_name): ...
         )
     )
     stub_file.writelines(FUNCTION_LIST)
-    stub_file.write("\n    # methods from PythonLibCore")
+    stub_file.write("\n    # methods from library.")
     stub_file.writelines(pyi_boilerplate_append.splitlines(keepends=True))
diff --git a/src/SeleniumLibrary/__init__.pyi b/src/SeleniumLibrary/__init__.pyi
index 24c844d39..cd1e3c836 100644
--- a/src/SeleniumLibrary/__init__.pyi
+++ b/src/SeleniumLibrary/__init__.pyi
@@ -1,6 +1,9 @@
 from datetime import timedelta
 from typing import Any, Optional, Union
 
+from selenium.webdriver.remote.webdriver import WebDriver
+from selenium.webdriver.remote.webelement import WebElement
+
 class SeleniumLibrary:
     def __init__(
         self,
@@ -401,12 +404,25 @@ class SeleniumLibrary:
         error: Optional[str] = None,
         limit: Optional[int] = None,
     ): ...
-    # methods from PythonLibCore
+    # methods from library.
     def add_library_components(self, library_components): ...
     def get_keyword_names(self): ...
-    def run_keyword(self, name, args, kwargs=None): ...
-    def get_keyword_arguments(self, name): ...
-    def get_keyword_tags(self, name): ...
-    def get_keyword_documentation(self, name): ...
-    def get_keyword_types(self, name): ...
-    def get_keyword_source(self, keyword_name): ...
+    def run_keyword(self, name: str, args: tuple, kwargs: Optional[dict] = None): ...
+    def get_keyword_arguments(self, name: str): ...
+    def get_keyword_tags(self, name: str): ...
+    def get_keyword_documentation(self, name: str): ...
+    def get_keyword_types(self, name: str): ...
+    def get_keyword_source(self, keyword_name: str): ...
+    def failure_occurred(self): ...
+    def register_driver(self, driver: WebDriver, alias: str): ...
+    @property
+    def driver(self) -> WebDriver: ...
+    def find_element(self, locator: str, parent: Optional[WebElement] = None): ...
+    def find_elements(self, locator: str, parent: WebElement = None): ...
+    def _parse_plugins(self, plugins: Any): ...
+    def _parse_plugin_doc(self): ...
+    def _get_intro_documentation(self): ...
+    def _parse_listener(self, event_firing_webdriver: Any): ...
+    def _string_to_modules(self, modules: Any): ...
+    def _store_plugin_keywords(self, plugin): ...
+    def _resolve_screenshot_root_directory(self): ...


Test patch:
diff --git a/atest/acceptance/keywords/run_on_failure.robot b/atest/acceptance/keywords/run_on_failure.robot
index 0752de5b1..80471fdb8 100644
--- a/atest/acceptance/keywords/run_on_failure.robot
+++ b/atest/acceptance/keywords/run_on_failure.robot
@@ -1,5 +1,5 @@
 *** Settings ***
-Suite Setup       Run Keywords    Go To Front Page    Set Info Loglevel    Prefer Custom Keywords
+Suite Setup       Run Keywords    Go To Front Page    Set Info Loglevel
 Test Teardown     Register Keyword to Run On Failure    Nothing
 Suite Teardown    Set Debug Loglevel
 Resource          ../resource.robot
@@ -11,10 +11,12 @@ ${FAILURE MESSAGE}    Page should not have contained text 'needle'.
 
 *** Test Cases ***
 Run On Failure Keyword Only Called Once
+    [Setup]    Prefer Custom Keywords
     Set Test Variable    ${ON FAIL COUNT}    ${0}
     Register Keyword To Run On Failure    On Fail
     Run Keyword And Ignore Error    Custom Selenium Keyword
     Should Be Equal    ${ON FAIL COUNT}    ${1}    On Failure Keyword called ${ON FAIL COUNT} times.
+    [Teardown]    Set Library Search Order    SeleniumLibrary
 
 Log Title On Failure
     [Documentation]
@@ -30,7 +32,7 @@ Disable Run on Failure With Nothing
     [Documentation]
     ...    LOG 1 No keyword will be run on failure.
     ...    LOG 2.1:2 NONE
-    SeleniumLibrary.Register Keyword to Run On Failure    Nothing
+    Register Keyword to Run On Failure    Nothing
     Run Keyword And Expect Error
     ...    ${FAILURE MESSAGE}
     ...    Page Should Not Contain    needle    loglevel=None
@@ -39,7 +41,7 @@ Disable Run on Failure With Python None
     [Documentation]
     ...    LOG 1 No keyword will be run on failure.
     ...    LOG 2.1:2 NONE
-    SeleniumLibrary.Register Keyword to Run On Failure    ${NONE}
+    Register Keyword to Run On Failure    ${NONE}
     Run Keyword And Expect Error
     ...    ${FAILURE MESSAGE}
     ...    Page Should Not Contain    needle    loglevel=None
@@ -48,7 +50,7 @@ Disable Run on Failure With String NONE
     [Documentation]
     ...    LOG 1 No keyword will be run on failure.
     ...    LOG 2.1:2 NONE
-    SeleniumLibrary.Register Keyword to Run On Failure    NONE
+    Register Keyword to Run On Failure    NONE
     Run Keyword And Expect Error
     ...    ${FAILURE MESSAGE}
     ...    Page Should Not Contain    needle    loglevel=None