Exemple #1
0
def test_open_google():
    browser = connect(FIREFOX)  # Get local session of firefox
    browser.get("http://www.google.com/")  # Load page
    assert browser.get_title() == "Google"
    print browser.get_cookies()
    elem = browser.find_element_by_name("q")  # Find the query box
    elem.send_keys("teste 123\n")
    sleep(0.2)  # Let the page load, will be added to the API
    #     try:
    #         browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")
    #     except NoSuchElementException:
    #         assert 0, "can't find seleniumhq"
    browser.close()
Exemple #2
0
    def startTest(self, test):
        from django.conf import settings
        test_instance = test.test
        if not self.server_started:
            if not self.check_database_multithread_compilant():
                return
            self.start_server(
                address=getattr(settings, "LIVE_SERVER_ADDRESS", DEFAULT_LIVE_SERVER_ADDRESS),
                port=int(getattr(settings, "LIVE_SERVER_PORT", DEFAULT_LIVE_SERVER_PORT))
            )
            self.server_started = True
            
        if not test_instance:
            return

        from selenium import FIREFOX
        browser = connect(getattr(settings, "SELENIUM_BROWSER", FIREFOX))
        #          getattr(settings, "SELENIUM_HOST", 'localhost'),
        #          int(getattr(settings, "SELENIUM_PORT", 4444)),
        #          getattr(settings, "SELENIUM_BROWSER_COMMAND", '*opera'),
        #          getattr(settings, "SELENIUM_URL_ROOT", get_live_server_path()),
        #      )
        # clear test client for test isolation
        test_instance.browser = browser
# -*- coding: utf-8 -*-
"""Sample usage of Selenium with Python client.

See `Python bindings of Python
<http://pypi.python.org/pypi/selenium>`_ on pypi.

Try it out with `nose` after running selenium-server. ::

    $ nosetests d83
"""
from selenium.remote import connect
from selenium import CHROME
from selenium.common.exceptions import NoSuchElementException
from time import sleep

browser = connect(CHROME)  # Get local session of Google Chrome
browser.get("http://www.google.co.jp")  # Load page
assert browser.get_title() == "Google"
elem = browser.find_element_by_name("q")  # Find the query box
elem.send_keys("selenium")
browser.find_element_by_name("btnG").click()
sleep(0.2)  # Let the page load, will be added to the API
try:
    browser.find_element_by_xpath(
            """//a[contains(@href,"http://seleniumhq.org")]""")
except NoSuchElementException:
    assert 0, "can't find seleniumhq on search result."
browser.close()

# vim: set et ts=4 sw=4 cindent fileencoding=utf-8 :
HOST = 'http://google.com'
print 'Connect to %s' % (HOST,)

TEST_USER = []
username = getpass.getpass('Username> ')
if username:
    TEST_USER.append(username)
else:
    sys.exit(1)
password = getpass.getpass('Password> ')
if password:
    TEST_USER.append(password)
else:
    sys.exit(1)

BROWSER = connect(CHROME)


def load(path):
    BROWSER.get(HOST + path)
    return BROWSER


class WebServiceTest(unittest.TestCase):

    def setUp(self):
        browser = load('/')
        # Move login page.
        try:
            browser.find_element_by_id('gb_70').click()
        except NoSuchElementException:
Exemple #5
0
 def setUp(self):
     self.b = connect(FIREFOX)