Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def dismiss_dialog(self, button_id):
self.wait_for_element_to_be_clickable((By.ID, button_id), wait_seconds=15)
self.browser.find_element_by_id(button_id).click()
self.wait_for_element_to_be_invisible((By.ID, button_id), wait_seconds=15)
_acknowledge_deletion_checkbox_locator = (By.CSS_SELECTOR, '.acknowledge')
_cancel_button_locator = (By.CSS_SELECTOR, 'a.cancel')
_update_button_locator = (By.ID, 'form-submit')
_full_name_field_locator = (By.ID, 'id_full_name')
_website_field_locator = (By.ID, 'id_externalaccount_set-0-identifier')
_bio_field_locator = (By.ID, 'id_bio')
_skills_field_locator = (By.CSS_SELECTOR, '#id_skills + ul input')
_groups_locator = (By.CSS_SELECTOR, "#groups .tagit-label")
_skills_locator = (By.CSS_SELECTOR, "#skills .tagit-label")
_voucher_name_locator = (By.CSS_SELECTOR, '#vouches .vouched')
_username_field_locator = (By.ID, 'id_username')
_delete_profile_button_locator = (By.CSS_SELECTOR, '.delete')
_delete_skill_buttons_locator = (By.CSS_SELECTOR, '#skills .tagit-close')
_select_month_locator = (By.ID, 'id_date_mozillian_month')
_select_year_locator = (By.ID, 'id_date_mozillian_year')
_month_locator = (By.CSS_SELECTOR, '#id_date_mozillian_month > option')
_year_locator = (By.CSS_SELECTOR, '#id_date_mozillian_year > option')
_selected_month_locator = (By.CSS_SELECTOR, '#id_date_mozillian_month > option[selected="selected"]')
_selected_year_locator = (By.CSS_SELECTOR, '#id_date_mozillian_year > option[selected="selected"]')
_find_group_page = (By.PARTIAL_LINK_TEXT, 'find the group')
_services_bugzilla_locator = (By.ID, 'services-bugzilla-url')
_services_mozilla_reps_locator = (By.ID, 'services-mozilla-reps')
def click_update_button(self):
self.find_element(*self._update_button_locator).click()
return Profile(self.selenium, self.base_url)
def click_cancel_button(self):
self.find_element(*self._cancel_button_locator).click()
def click_find_group_link(self):
def test_user_profile_in_mm(base_url, selenium):
# Check that the edit button is not displayed for a user profile.
page = BasePage(selenium, base_url)
page.URL_TEMPLATE = '/{locale}/profiles/test-moderator'
page.open()
assert not page.is_element_displayed(By.ID, 'edit-user')
assert page.is_maintenance_mode_banner_displayed
assert not page.header.is_signin_displayed
# TODO: so there is a paginator on the top and bottom of the region, should we randomize which one is selected
# 130529 - dajo - had to change from #paging_div since the classes are slightly different depending on how the page
# is loaded... mgmt_system all_vms click through versus services tab > VMs
#Navigation
_first_page_locator = (By.CSS_SELECTOR, "#pc_div_1 * img[alt='First']")
_prev_locator = (By.CSS_SELECTOR, "#pc_div_1 * img[alt='Previous']")
_next_locator = (By.CSS_SELECTOR, "#pc_div_1 * img[alt='Next']")
_last_page_locator = (By.CSS_SELECTOR, "#pc_div_1 * img[alt='Last']")
_per_page_locator = (By.CSS_SELECTOR, "#pc_div_1 * select[name='ppsetting']")
#Position
_position_text_locator = (By.CSS_SELECTOR, '#pc_div_1 > table > tbody > tr > td > table > tbody > tr > td:last-child')
_position_regex = '(\d+)[-]?(\d+)? of (\d+)\)'
# Selection
_select_all_checkbox_locator = (By.ID, "masterToggle")
def click_first_page(self):
self.selenium.find_element(*self._first_page_locator).click()
self._wait_for_results_refresh()
def click_prev_page(self):
self.selenium.find_element(*self._prev_locator).click()
self._wait_for_results_refresh()
@property
def is_prev_page_disabled(self):
return 'dimmed' in self.selenium.find_element(*self._prev_locator).get_attribute('class')
@property
def is_first_page_disabled(self):
return 'dimmed' in self.selenium.find_element(*self._first_page_locator).get_attribute('class')
from pypom import (Page,
Region)
from selenium.webdriver.common.by import By
class Base(Page):
@property
def header(self):
return self.Header(self)
class Header(Region):
_root_locator = (By.ID, 'th-global-navbar')
_app_menu_locator = (By.ID, 'th-logo')
_app_logo_locator = (By.CSS_SELECTOR, '#th-logo img')
_switch_app_locator = (By.CSS_SELECTOR, '#th-logo + div > a')
@property
def active_app(self):
# Initially try to compare with the text of the menu item.
# But if there's an image instead of just text, then compare the
# ``alt`` property of the image instead.
self.wait.until(lambda _: self.is_element_displayed(
*self._app_menu_locator))
menu = self.find_element(*self._app_menu_locator).text
return menu if menu else self.find_element(
*self._app_logo_locator).get_attribute("alt")
def switch_app(self):
combobox_source=ui.ComboBox(By.NAME, 'snapshot_source'),
combobox_type=ui.ComboBox(By.NAME, 'type'),
field_description=ui.TextField(By.NAME, 'description'),
field_name=ui.TextField(By.NAME, 'name'),
field_size=ui.IntegerField(By.NAME, 'size'))
class FormCreateVolume(_ui.Form):
"""Form to create volume from snapshot."""
@ui.register_ui(
button_delete_snapshots=ui.Button(By.ID,
'volume_snapshots__action_delete'),
form_create_volume=FormCreateVolume(By.CSS_SELECTOR,
'form[action*="volumes/create"]'),
form_edit_snapshot=FormCreateSnapshot(By.ID, 'update_snapshot_form'),
table_snapshots=TableSnapshots(By.ID, 'volume_snapshots'))
class TabSnapshots(_ui.Tab):
"""Volume snapshots tab."""
def find_element(self, by=By.ID, value=None):
return self._execute_on_webelement(
lambda it: it.find_element(by, value),
condition=be.in_dom)
# return self.__delegate__.find_element(by, value) # todo: remove
def measure(webdriver, interaction):
page.go_to_url(f"{BITBUCKET_SETTINGS.server_url}/plugin/dashboard")
page.wait_until_visible((By.ID, 'dashboard_app_element_id'), interaction)
def find_element_by_id(self, id_):
"""Finds an element by id.
:Args:
- id\_ - The id of the element to be found.
:Usage:
driver.find_element_by_id('foo')
"""
return self.find_element(by=By.ID, value=id_)
UPLOAD_AN_IMAGE = {
'google': (By.LINK_TEXT, 'Upload an image'),
'bing': (By.LINK_TEXT, 'upload an image'),
# //*[@id="stfile"]
'baidu': '//*[@id="uploadImg"]',
}
CHOOSE_FILE = {
'google': (By.ID, 'qbfile'),
'bing': (By.CSS_SELECTOR, 'input[type="file"]'),
'baidu': (By.CSS_SELECTOR, 'input[type="file"]'),
}
SHOW_IMAGE_RESULTS = {
'google': (By.LINK_TEXT, 'Visually similar images'),
'bing': (By.ID, 'mmComponent_images_4_1_1_exp'),
'baidu': (By.XPATH, '//*[@id="imglist"]/div/div/a[@class="imglist-more"]'),
}
SHOW_MORE_RESULTS_XPATH = {
'google': '//*[@id="smb"]',
# //*[@id="mmComponent_images_4_1_1_exp"]/a
'bing': '//*[@id="mmComponent_images_4_1_1_exp"]/a',
# //*[@id="imglist"]/div/div[1]/a
'baidu': '//*[@id="imglist"]/div/div/a[@class="imglist-more"]',
}
def get_url(url, search_engine):
if search_engine is 'google':
starts_with = '/imgres?imgurl='
img_tag = '/imgres?imgurl='