Framework.ClassUtils.WSelenium package

Submodules

Framework.ClassUtils.WSelenium.browser_mgmt module

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class Framework.ClassUtils.WSelenium.browser_mgmt.BrowserManagement(*args, **kwargs)[source]

Bases: object

Browser management class

check_url(url)[source]

To check whether the user provided url is valid or not.

DISCLAIMER: This function internally opens the url to assert the validity of the url.

Returns:
  1. status(bool)= True / False.(Whether the url can be reached)
  2. url : The actual url itself
close_browser(browser_instance=None)[source]

closes a browser session

close_tab(browser_instance=None, tab_number=None, browser_type='firefox')[source]

Closing tabs in a browser with unique tab_number

close_window(browser_instance=None)[source]

close the current window

Delete a specific cookie on a specific browser instance

delete_all_cookies_in_browser(browser_instance=None)[source]

Delete the cookies for a particular browser instance

get_browser_version(browser)[source]

Get browser version from selenium

get_firefox_version(binary)[source]

Use firefox binary to find out firefox version before launching firefox in selenium

get_window_position(browser_instance=None)[source]

Returns current window position as x then y.

get_window_size(browser_instance=None)[source]

Returns current window size as width then height.

go_back(browser_instance=None)[source]

Simulates the user clicking the “back” button on their browser.

go_forward(browser_instance=None)[source]

Simulates the user clicking the “back” button on their browser.

go_to(url, browser_instance=None)[source]

Navigates the active browser instance to the provided URL.

hard_reload_page(browser_instance=None)[source]

Simulates Refreshing/Reloading the page just as users using F5

maximize_browser_window(browser_instance=None, headless_mode=False)[source]

Maximizes current browser window.

open_browser(browser_name='firefox', webdriver_remote_url=False, desired_capabilities=None, **kwargs)[source]

Open a browser session

open_tab(browser_instance=None, url=None, browser_type='firefox')[source]

Opens a new tab in the browser

reload_page(browser_instance=None)[source]

Simulates user reloading page.

save_screenshot(browser_instance=None, filename=None, directory=None)[source]

Save screenshot of the specified/current browser

set_firefox_proxy(profile_dir, proxy_ip, proxy_port)[source]

method to update the given preferences in Firefox profile

set_window_position(x, y, browser_instance=None)[source]

Sets the position x and y of the current window to the specified values.

set_window_size(width, height, browser_instance=None)[source]

Sets the width and height of the current window to the specified values.

switch_tab(browser_instance=None, tab_number=None, browser_type='firefox')[source]

Switching to different tabs in a browser with unique tab_number

Framework.ClassUtils.WSelenium.element_locator module

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class Framework.ClassUtils.WSelenium.element_locator.ElementLocator(*args, **kwargs)[source]

Bases: object

Element Locator class

get_element(browser, locator, **kwargs)[source]

Get an element based on the locator and value - By defaults gets a single element, - To get the list of all elements matching the value use findall=’y’ as argument.

Arguments:
  • browser = instance of selenium webdriver browser.

  • locator = how to locate the element in the webpage.

    supported format: “supported locator value = value for the locator” 1. to locate element by its id:

    format = “id=id of the element” eg: “id=j_username” will find the element whose id is j_username

    1. “name=name of the element”
    2. “xpath=xpath of the element”
    3. “link=link to the element”
    4. “partial_link=partial link to the element”
    5. “tag=tag of the element”
    6. “class=class of the element”
    7. “css=css of the element”
  • **kwargs:
    1. findall = ‘y’ - finds all the elements with matching value
      = None - finds the first elemtn with matching value.
Returns:
  • the selenium webdriver element if found.
  • None if element was not found

(prints a NoSuchElementException message to the user)

Framework.ClassUtils.WSelenium.element_operations module

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class Framework.ClassUtils.WSelenium.element_operations.ElementOperations(*args, **kwargs)[source]

Element operations

get_page_source(browser)[source]

Get page source of the browser

perform_element_action(element_or_browser, locator=None, action=None, **kwargs)[source]

Generic method to perform specific actions on an element :Currently supported actions and the values that they take if the user provided action is “get_text”, it would return the value of the particular element and the status of it. If not it would return only the status

verify_text(**kwargs)[source]

stores the text from element in data repository with var variable and verifies if it is same as expected if expected is provided :Arguments:

  1. var = variable in which to store the text
  2. expected = value to compare with as a list separated by comma
wait_time(count, browser, locator, action)[source]

wait time to find the element again

Framework.ClassUtils.WSelenium.verify_operations module

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class Framework.ClassUtils.WSelenium.verify_operations.VerifyOperations(*args, **kwargs)[source]

Bases: object

Browser management class

get_page_property(browser_instance, value_type=None)[source]
verify_alert_is_present(browser_instance, action='accept')[source]

Framework.ClassUtils.WSelenium.wait_operations module

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class Framework.ClassUtils.WSelenium.wait_operations.WaitOperations(*args, **kwargs)[source]

Wait operations class

implicit_wait(browser_instance, timeout)[source]
wait_until_element_is_clickable(browser_instance, locator_type, locator, timeout=5)[source]
wait_until_presence_of_all_elements_located(browser_instance, locator_type, locator, timeout=5)[source]
wait_until_presence_of_element_located(browser_instance, locator_type, locator, timeout=5)[source]
wait_until_visibility_of_element_located(browser_instance, locator_type, locator, timeout=5)[source]
wait_until_visibilty_is_confirmed(browser_instance, element, timeout=5)[source]

Module contents

Copyright 2017, Fujitsu Network Communications, Inc. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.