How to use the selenium.webdriver.common.by.By function in selenium

To help you get started, we’ve selected a few selenium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plotly / dash-cytoscape / tests / test_callbacks.py View on Github external
def click_button_and_save(name_to_xpaths, dir_name, save=True):
            for name, xpath in name_to_xpaths.items():
                button = self.driver.find_element(By.XPATH, xpath)
                button.click()

                if save:
                    WebDriverWait(self.driver, 20).until(
                        EC.presence_of_element_located((By.ID, "cytoscape"))
                    )

                    path = os.path.join(
                        os.path.dirname(__file__),
                        'screenshots',
                        dir_name,
                        name + '.png'
                    )

                    self.driver.save_screenshot(path)
github Yadoms / yadoms / tests / user / dashboard / automation / __init__.py View on Github external
def waitEditRuleModal(browser):
   WebDriverWait(browser, 10).until(Condition.visibility_of_element_located((By.ID, 'edit-automation-rule-modal')))
   modals.waitForOpened(browser.find_element_by_id('edit-automation-rule-modal'))
   return EditRuleModal(browser.find_element_by_id('edit-automation-rule-modal'))
github mozilla-lockwise / lockbox-extension / test / integration / pages / login.py View on Github external
"""Login page locators and functions."""

from pypom import Page
from selenium.webdriver.common.by import By

from pages.home import Home
from pages.util.util import munged_class_name


class Login(Page):
    """Set up the login page locators and functions."""

    _password_locator = (By.NAME, 'password')
    _confirm_password_locator = (By.NAME, 'confirmPassword')
    _continue_locator = (By.CSS_SELECTOR, 'button.{}'.format(
                         munged_class_name('button')))

    def wait_for_page_to_load(self):
        """Page load wait."""
        self.wait.until(
            lambda s: s.find_elements(*self._password_locator))
        return self

    def login(self, password):
        """Login to lockbox."""
        self.find_element(*self._password_locator).send_keys(password)
        self.find_element(*self._confirm_password_locator).send_keys(password)
        window_handles = self.selenium.window_handles
        self.find_element(*self._continue_locator).click()
github everware / everware / frontend_tests / happy_scenarios.py View on Github external
def scenario_short(user):
    driver = user.get_driver()
    driver.get(user.base_url + "/hub/login")
    user.log("login")
    driver.find_element_by_id("username_input").clear()
    driver.find_element_by_id("username_input").send_keys(user.login)
    driver.find_element_by_id("password_input").clear()
    driver.find_element_by_id("password_input").send_keys(user.password)
    driver.find_element_by_id("login_submit").click()
    user.wait_for_element_present(By.ID, "start")
    driver.find_element_by_id("logout").click()
    user.log("logout clicked")
github freenas / webui / tests / selenium / tasks_periodicSS.py View on Github external
def test_01_nav_tasks_periodicSS(self):
        try:
            driver.find_element_by_xpath(xpaths['submenuPeriodicSS']).click()
            # cancelling the tour
            if self.is_element_present(By.XPATH,'/html/body/div[6]/div[1]/button'):
                driver.find_element_by_xpath('/html/body/div[6]/div[1]/button').click()
            # get the ui element
            ui_element=driver.find_element_by_xpath('//*[@id="breadcrumb-bar"]/ul/li[2]/a')
            # get the weather data
            page_data=ui_element.text
            print ("the Page now is: " + page_data)
            # assert response
            self.assertTrue("Periodic Snapshot Tasks" in page_data)
            #taking screenshot
            function.screenshot(driver, self)
        except Exception:
            exc_info_p = traceback.format_exception(*sys.exc_info())
            #taking screenshot
            function.screenshot(driver, self)
            for i in range(1,len(exc_info_p)):
                print (exc_info_p[i].rstrip())
github danielireson / facebook-bulk-group-inviter / cli / browser.py View on Github external
def enter_login_details(self, email, password):
    try:
      print('Entering login details')
      email_field = self.browser.find_element_by_id('email')
      pass_field = self.browser.find_element_by_id('pass')
      email_field.send_keys(email)
      pass_field.send_keys(password)
      pass_field.submit()
      element_present = expected_conditions.presence_of_element_located((By.ID, 'userNavigationLabel'))
      WebDriverWait(self.browser, self.delay).until(element_present)
    except TimeoutException:
      sys.exit('Login with your credentials unsuccessful')
github inspirehep / inspire-next / inspirehep / bat / pages / holdingpen_author_list.py View on Github external
def load_submission_record(input_data):
    def _load_submission_record():
        return (
            'CERN' in record and
            'cond-mat' in record and
            'astro-ph' in record and
            'Twain, Mark' in record and
            'admin@inspirehep.net' in record
        )

    try:
        record = WebDriverWait(Arsenic(), 10).until(
            GetText(
                (By.XPATH, '//div[@class="row hp-item ng-scope"][1]')
            )
        )
    except (ElementNotVisibleException, WebDriverException):
        go_to()
        return load_submission_record(input_data)

    return ArsenicResponse(_load_submission_record)
github pradyumnac / AliexpressOrders / aliexpress.py View on Github external
dcap = dict(DesiredCapabilities.PHANTOMJS)
        dcap["phantomjs.page.settings.userAgent"] = (UA_STRING)
        driver = webdriver.PhantomJS(desired_capabilities=dcap)
    else:
        raise Exception("Invalid Driver Type:" + drivertype)
    driver.set_window_size(1366, 680)
    driver.get("https://login.aliexpress.com/express/mulSiteLogin.htm?spm=2114.11010108.1000002.7.9c5Rcg&return=http%3A%2F%2Fwww.aliexpress.com%2F")
    driver.switch_to_frame(driver.find_element_by_id("alibaba-login-box"))
    element = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.ID, "fm-login-id"))
    )
    element.send_keys(email)
    driver.find_element_by_xpath("//*[@id=\"fm-login-password\"]").send_keys(passwd)
    driver.find_element_by_id("fm-login-submit").click()
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "search-key"))
    )
    driver.get("http://trade.aliexpress.com/orderList.htm?spm=2114.11010108.1000002.18.bT7Uae")
    
    # ua = driver.find_element_by_id("nav-user-account")
    # hov = ActionChains(driver).move_to_element(ua)
    # hov.perform()
    # 1/0
    aliexpress = {}
    
    elemAwaitingShipment = driver.find_element_by_id("remiandTips_waitSendGoodsOrders")
    intAwaitingShipment = elemAwaitingShipment.get_attribute("innerText").split("(")[1].strip(")")
    elemAwaitingShipment.click()
    aliexpress['Not Shipped'] = parse_orders(driver, 'ae1.html','webread')
    
    elemAwaitingDelivery = driver.find_element_by_id("remiandTips_waitBuyerAcceptGoods")
    intAwaitingDelivery = elemAwaitingDelivery.get_attribute("innerText").split("(")[1].strip(")")
github SeleniumHQ / selenium / py / selenium / webdriver / remote / webelement.py View on Github external
    def find_elements(self, by=By.ID, value=None):
        """
        Find elements given a By strategy and locator. Prefer the find_elements_by_* methods when
        possible.

        :Usage:
            ::

                element = element.find_elements(By.CLASS_NAME, 'foo')

        :rtype: list of WebElement
        """
        if self._w3c:
            if by == By.ID:
                by = By.CSS_SELECTOR
                value = '[id="%s"]' % value
            elif by == By.TAG_NAME:
github Mirantis / stepler / stepler / horizon / app / pages / volumes / tab_volumes.py View on Github external
class FormEditVolume(_ui.Form):
    """Form to edit volume."""


@ui.register_ui(
    item_change_volume_type=ui.UI(By.CSS_SELECTOR, '*[id$="action_retype"]'),
    item_create_backup=ui.UI(By.CSS_SELECTOR, '[id$="action_backups"]'),
    item_create_snapshot=ui.UI(By.CSS_SELECTOR, 'a[id$="action_snapshots"]'),
    item_create_transfer=ui.UI(By.CSS_SELECTOR,
                               '[id$="action_create_transfer"]'),
    item_extend_volume=ui.UI(By.CSS_SELECTOR, '*[id$="action_extend"]'),
    item_launch_volume_as_instance=ui.UI(By.CSS_SELECTOR,
                                         '*[id$="action_launch_volume_ng"]'),
    item_manage_attachments=ui.UI(By.CSS_SELECTOR,
                                  '[id$="action_attachments"]'),
    item_upload_to_image=ui.UI(By.CSS_SELECTOR,
                               '*[id$="action_upload_to_image"]'))
class DropdownMenu(_ui.DropdownMenu):
    """Dropdown menu for volume row."""


@ui.register_ui(
    checkbox=_ui.CheckBox(By.CSS_SELECTOR, 'input[type="checkbox"]'),
    dropdown_menu=DropdownMenu(),
    link_volume=ui.UI(By.CSS_SELECTOR, 'td > a'))
class RowVolume(_ui.Row):
    """Volume row of volumes table."""

    transit_statuses = ('Attaching',
                        'Creating',
                        'Detaching',
                        'downloading',