Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.driver.find_element(By.XPATH, "//div[@id='"+gradeable_id+"']//*[contains(@class, 'fa-pencil-alt')]").click()
if allowed:
self.driver.find_element(By.ID, "yes_regrade_allowed").click()
else:
self.driver.find_element(By.ID, "no_regrade_allowed").click()
# set deadline
if date is not None:
self.driver.find_element(By.XPATH, "//a[text()='Dates']").click()
grade_inquiry_date_input = self.driver.find_element(By.NAME, "regrade_request_date")
# wait for flatpickr to appear
grade_inquiry_date_input.click()
wait = WebDriverWait(self.driver, self.WAIT_TIME)
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#date_regrade_request.active")))
# then input new date
grade_inquiry_date_input.clear()
grade_inquiry_date_input.send_keys(date,Keys.ENTER)
# navigate back to gradeable page
self.driver.find_element(By.ID, "nav-sidebar-submitty").click()
def wait_for_element_by_css_selector(self, selector):
return WebDriverWait(self.driver, TIMEOUT).until(
EC.presence_of_element_located((By.CSS_SELECTOR, selector))
)
# -*- coding: utf-8 -*-
from pages.page import Page
from selenium.webdriver.common.by import By
class QuadiconItem(Page):
'''Extend this class to create a custom QuadiconItem
Add additional properties in order to customize the lookup
'''
_quadlink_locator = (By.CSS_SELECTOR, '#quadicon > div > a')
_checkbox_locator = (By.CSS_SELECTOR, '#listcheckbox')
_label_link_locator = (By.CSS_SELECTOR, 'tr > td > a')
_quad_tl_locator = (By.CSS_SELECTOR, '#quadicon > .a72')
_quad_tr_locator = (By.CSS_SELECTOR, '#quadicon > .b72')
_quad_bl_locator = (By.CSS_SELECTOR, '#quadicon > .c72')
_quad_br_locator = (By.CSS_SELECTOR, '#quadicon > .d72')
def __init__(self, testsetup, quadicon_list_element):
Page.__init__(self, testsetup)
self._root_element = quadicon_list_element
def click(self):
self._root_element.find_element(*self._quadlink_locator).click()
@property
def title(self):
return self._root_element.find_element(*self._label_link_locator).get_attribute('title')
# warm the cache
browser.get("/learners")
for num, (run_scenario, name) in learners_state_iter:
skip_screenshot = False
with django_db_blocker.unblock():
learners_states.user.refresh_from_db()
filename = make_filename(num, name, output_directory=output_directory, use_mobile=use_mobile)
new_url = run_scenario()
if not skip_screenshot:
browser.get(new_url)
browser.wait_until_loaded(By.CSS_SELECTOR, '.sk-hits,.no-hits')
browser.wait_until_loaded(By.CLASS_NAME, 'micromasters-title')
try:
browser.click_when_loaded(
By.CSS_SELECTOR,
'.filter--company_name .Select-arrow-zone',
retries=0,
)
except ElementNotVisibleException:
# We are trying to make the work history visible, but if it doesn't exist
# there's nothing to do
pass
# sometimes the browser scrolls down for some reason after clicking
browser.driver.execute_script("window.scrollTo(0, 0)")
browser.take_screenshot(filename=filename)
with django_db_blocker.unblock():
terminate_db_connections()
seeded_database_loader.load_backup()
@return: CopyCondition
"""
return self.select_condition(name).copy()
class ConditionView(Conditions, ReloadMixin):
""" General view on a condition's summary
"""
_scope_locator = (By.XPATH, "//*[@id='condition_info_div']/fieldset[1]")
_expression_locator = (By.XPATH, "//*[@id='condition_info_div']/fieldset[2]")
_assigned_policies_table_locator = (By.XPATH, "//*[@id='condition_info_div']/fieldset[4]/table")
_configuration_button_locator = (By.CSS_SELECTOR, "div.dhx_toolbar_btn[title='Configuration']")
_configuration_delete_cond_locator = (By.CSS_SELECTOR,
"tr[title*='Delete this']")
_configuration_edit_cond_locator = (By.CSS_SELECTOR,
"tr[title='Edit this Condition']")
_configuration_copy_cond_locator = (By.CSS_SELECTOR,
"tr[title*='Copy this Condition to a new Condition']")
_notes_textarea_locator = (By.CSS_SELECTOR, "textarea#notes")
@property
def notes_textarea(self):
return self.selenium.find_element(*self._notes_textarea_locator)
@property
def configuration_button(self):
return self.selenium.find_element(*self._configuration_button_locator)
:Usage:
element = driver.find_element(By.ID, 'foo')
:rtype: WebElement
"""
if self.w3c:
if by == By.ID:
by = By.CSS_SELECTOR
value = '[id="%s"]' % value
elif by == By.TAG_NAME:
by = By.CSS_SELECTOR
elif by == By.CLASS_NAME:
by = By.CSS_SELECTOR
value = ".%s" % value
elif by == By.NAME:
by = By.CSS_SELECTOR
value = '[name="%s"]' % value
return self.execute(Command.FIND_ELEMENT, {
'using': by,
'value': value})['value']
link = soup.findAll("a", {"class": "rc-audiochallenge-tdownload-link"})[0]
urllib.urlretrieve(link["href"], TASK_PATH + "/" + TASK + ".mp3")
guess_str = get_numbers(TASK_PATH + "/" + TASK, TASK_PATH + "/")
type_style(driver, "audio-response", guess_str)
# results.append(guess_str)
wait_between(0.5, 3)
driver.find_element(By.ID, "recaptcha-verify-button").click()
wait_between(1, 2.5)
try:
logging.debug("Checking if Google wants us to solve more...")
driver.switch_to.default_content()
driver.switch_to.frame(iframeSwitch)
checkmark_pos = driver.find_element(By.CLASS_NAME, "recaptcha-checkbox-checkmark").get_attribute("style")
guess_again = not (checkmark_pos == "background-position: 0 -600px")
driver.switch_to.default_content()
iframe = driver.find_element(By.CSS_SELECTOR, "iframe[title=\"recaptcha challenge\"]")
driver.switch_to.frame(iframe)
except Exception as e:
print e
guess_again = False
input("")
main()
"""Form to update image metadata."""
submit_locator = By.CSS_SELECTOR, '.btn[ng-click$="modal.save()"]'
cancel_locator = By.CSS_SELECTOR, '.btn[ng-click$="modal.cancel()"]'
class FormUpdateImage(FormImage):
"""Form to update image."""
@ui.register_ui(
field_name=ui.TextField(By.CSS_SELECTOR, 'input[ng-model$=".name"]'),
field_description=ui.TextField(By.CSS_SELECTOR,
'input[ng-model$=".description"]'),
field_size=ui.TextField(By.CSS_SELECTOR, 'input[ng-model$=".size"]'),
combobox_volume_type=ui.ComboBox(By.CSS_SELECTOR,
'input[ng-model$=".volumeType"]'))
class FormCreateVolume(_ui.Form):
"""Form to create volume."""
@ui.register_ui(
button_create_image=ui.Button(By.XPATH,
'.//button[contains(., "Create Image")]'),
button_delete_images=ui.Button(By.XPATH,
'.//button[contains(., "Delete Images")]'),
button_public_images=ui.Button(By.CSS_SELECTOR, 'button[value="public"]'),
form_create_image=FormCreateImage(By.XPATH, './/*[@ng-form="wizardForm"]'),
form_create_volume=FormCreateVolume(By.XPATH,
'.//*[@ng-form="wizardForm"]'),
form_launch_instance=FormLaunchInstance(
By.CSS_SELECTOR,
"""Return dict of image properties from block."""
_properties = {}
for name_el in self.find_elements(self._property_name_locator):
name = name_el.get_attribute('innerText')
value_el = name_el.find_element(*self._property_value_locator)
value = value_el.get_attribute('innerText')
_properties[name] = value
return _properties
@ui.register_ui(
image_info_main=Info(By.XPATH,
'.//div[./h3[.="Image"]]'),
image_info_custom=Info(By.XPATH,
'.//div[./h3[.="Custom Properties"]]'),
label_name=ui.UI(By.CSS_SELECTOR, '.h1'))
class PageImage(PageBase):
"""Image page."""
url = "/project/images/{id}/"
# See the License for the specific language governing permissions and
# limitations under the License.
from pom import ui
from selenium.webdriver.common.by import By
from ..base import PageBase
from .tab_api_access import TabApiAccess
from .tab_floating_ips import TabFloatingIPs
from .tab_keypairs import TabKeypairs
from .tab_security_groups import TabSecurityGroups
@ui.register_ui(
label_api_access=ui.UI(
By.CSS_SELECTOR, '[data-target$="api_access_tab"]'),
label_floating_ips=ui.UI(
By.CSS_SELECTOR, '[data-target$="floating_ips_tab"]'),
label_keypairs=ui.UI(
By.CSS_SELECTOR, '[data-target$="keypairs_tab"]'),
label_security_groups=ui.UI(
By.CSS_SELECTOR, '[data-target$="security_groups_tab"]'),
tab_api_access=TabApiAccess(),
tab_floating_ips=TabFloatingIPs(),
tab_keypairs=TabKeypairs(),
tab_security_groups=TabSecurityGroups())
class PageAccess(PageBase):
"""Access & security page."""
url = "/project/access_and_security/"
navigate_items = "Project", "Compute", "Access & Security"