Package: eaiautomatontools
Automaton Tools moduleThe automaton tools module provide an abstraction of the selenium web driver through a "BrowserServer" object.Note on documentationThe documentation is build upon the doctest's files. It includes some weird sections such as "Teardown"
section: Don't be afraid is testing part ;)Documentation is onReadTheDocsSystem requirementsThis module has been developed with Python 3.7 and uses selenium version 3.14.All code is accessible onGitHubBrowserServer objectThe BrowserServer is packaged with the webdriver-manager. You can require:chromeheadless-chromefirefoxedgeoperasafari (it's not managed by webdriver-manager: you have to provide the path to the webdriver)Serve the webdriverWhen everything is set you can call "serve()" method which open the browser of the specified type.You can stop the webdriver by invoking the "close()" method.Interacting with the browserThe main feature is unifying the way you choose to interact with the browser.An element is described by a dictionary in which we give a type and a value.Thetypeis one of the following:id: the element identifier,name: the element name,class_name: the element class name,css: the element css path,link_text: the link full text,partial_link_text: the link partial text,tag_name: the element tag namexpath: the element xpathThevaluecontains the actual value for thetype. For example an element with the "id" type must havethe id's value to be correctly defined. In the same way an element with the "tag_name" type and a value "div" may return all div on the web page.To avoid, as much as possible, this multi-definition you can add atextdictionary key which try to locate the element with this exact text.You may find an element with an empty text so use it with care.Although the BrowserServer class is a must have, you can use the module spaces separately. I will quickly present here only the BrowserServer class method but the module spaces functions only add a "driver" attribute which hold the selemium web driver to use.findersThis module space is about finding and returning web element.find_element(field,[web_element]): return the first element which match the criteria. Use the web_element as base element in order to find nested element.find_elements(field, [web_element]): return all elements which match the criteria in a list. Use the web_element as base element in order to find nested element.find_from_elements(field,text, [web_element]): return the first element which match the criteria and has the text. Use the web_element as base element in order to find nested element.informationThis module space is about retrieving data from the web page or the browser.is_field_exist(field,until): return the first element which match the criteria within "until" second. Return None otherwise.is_field_contains_text(field,text): return true if the field contains the text even in the value, false otherwise.is_alert_present(until): return true if an alert is present within "until" second.element_text(field): return the field text.how_many_windows(): return the number of opened windows.is_field_displayed(field): return true if the field is displayed.is_field_enabled(field): return true if the field is enabled.navigatorsThis module space is about browsing tag and web browsing.go_to_url(url): return 0 if successful and go to the specified url.enter_frame(field): return 0 if successful and enter the page frame/iframe.go_to_window(handle,title): return 0 if successful and gain focus on the window defined by its handle ot its title.alertsThis module space is about the alert popups.intercept_alert(messages, accept, value): return 0 if successful. You can specify a list of message which one must be displayed on the alert, accept or reject the alert (Ok or dimiss) and enter a value where the alert prompt for a user input.alert_message(): return the alert message if an alert is displayed.actionsThis module space is about filling, selecting and clicking on web element.fill_element(field,value): return 0 if successful, fill the field with the valuefill_elements(fields, data): return 0 if successful, fill each field in the fields dictionary with the value hold in the data dictionary. You can have a larger fields dictionary than the data but each data entry must be found in the fields dictionary.select_in_dropdown(field,visible_text,value): return 0 if successful, select in the field dropdown the element either described by its visible text or its hidden value.click_element(field): return 0 if successful, perform a left click on the field.mouse_click(field): return 0 if successful, perform a chain action moving the mouse on the element and mouse click element.set_checked(field,is_checked): return 0 if successful, set the checkbox field so that the is_checked value is always true i.e. checked if is_checked set to true and not checked if is_checked set to false.Other documentationPlease find in the test folder doctest files which describe almost all methods here.Moreover don't hesitate to use the python help(method/class) directly from the python console in order to access the docstring.To DoAdd a multi-selection for dropdownAdd a drag & drop functionalityAdd a get handles functionalityRelease Notesversion 1.1.9:update path to find ChromeType in webdriver-manager packageversion 1.1.8:add information method to check if an element is in the viewportbrowserServer.is_element_in_viewport(field, [webElement])information.is_field_in_viewport(driver, field, [webElement])version 1.1.7:Rewrite __serve_chrome method to lower complexityversion 1.1.6:replaceselenium.webdriver.chrome.options.Options.headlesswithselenium.webdriver.chrome.options.Options.add_argument("--headless").
No clue on the reason the previous behaviour stopped working.version 1.1.5:fix removal of opera from webdriverclick_elementraise NoSuchElementException when element is not foundversion 1.1.4:fix merge issueversion 1.1.3:update import following webdriver manager change packaging structureversion 1.1.2:fix missing version in headless webdriverversion 1.1.1:add browser_version attribute. It allows to specify a browser version so that the webdriver manager will use this specific version.version 1.1.0:add selenium 4 support. Relative locator are not included in the current "field" modelversion 1.0.14:fix missingweb_elementvariable inBrowserServer.set_checkboxmethodaddmouse_clickmethod in the actionsversion 1.0.13:fix missingavoid_move_topassing value to find_from_elements when using find_element in conjunction withtextparameter.version 1.0.12:lower log level for finder(s) actionsadd wait_for_another_window in informationadd typing annotations and minimal docstring on BrowserServerfix test_01_01fix case browser_name is Noneversion 1.0.11:lower log level for polling actionsversion 1.0.10:add chromium from DriverManager in BrowserServerversion 1.0.9:actions and finders return None if element not foundversion 1.0.8:add avoid_move_to option on find_element in order to retrieve an element without moving to itadd minor testsversion 1.0.7:add caller_message to move_to method in order to track down issue in the logsadd execute_script method to BrowserServeris_displayed polls every 0.2s for 10s in order to check if field is displayedis_field_exist polls even with StaleElementReferenceExceptionuse polling2 instead of webdriver wait where applicableversion 1.0.6:new test server: now using flask as a test serveruse mkdocs and the doctest test repository in order to build the documentationadd diver option setteradd a generic move_to web element methodversion 1.0.5: Sorry for the interruptionuse webdriver manager in order to retrieve webdrivers.Enhance the webdriver handling.Allow providing a WebElement to find nested element(s).Enhance doctest coverage.Minor refactoringversion 0.1: first release