Beispiel #1
0
def setUp3(self):
        tp = tParams.GetParams()
        
        if tp.place.find("sauce") > -1:
            
            self.verificationErrors = []
            self.selenium = selenium(ct.DOMAIN, ct.PORT,
                                    "{\"username\": \"" + ct.USER_NAME + 
                                    "\",\"access-key\":\"" + ct.ACCESS_KEY + 
                                    "\",\"browser\": \"" + tp.test_browser + 
                                    "\",\"job-name\":\"" + self.__class__.__name__ + 
                                    "\",\"max-duration\":\"" + ct.MAX_DURATION +
                                    "\",\"record-video\":\"" + ct.RECORD_TEST + 
                                    "\",\"os\":\"" + ct.OS + 
                                    "\"}", 
                                    tp.run_domain)
            self.selenium.start()
        else:
            if tp.place.find("local") > -1  :
                self.verificationErrors = []
                tp = tParams.GetParams()
            if tp.test_browser.find("*firefox"):
                tp.test_browser = tParams.GetParams().test_browser
            if tp.run_domain.find("http://issuu.com"):
                tp.run_domain = tParams.GetParams().run_domain
            self.selenium = selenium("localhost", 4444, tp.test_browser, tp.run_domain)
            self.selenium.start()
    def setUp(self):
        configuration = NySeleniumConfig()
        self.verificationErrors = []
        supported_browsers = [ '*firefox', '*mock', '*firefoxproxy',
                             '*pifirefox', '*chrome', '*iexploreproxy',
                             '*iexplore', '*firefox3', '*safariproxy',
                             '*googlechrome', '*konqueror', '*firefox2',
                             '*safari', '*piiexplore', '*firefoxchrome',
                             '*opera', '*iehta', '*custom']
        browsers = configuration.data['browsers'].split(",")

        if(browsers[0] == '*all'):
            for browser in supported_browsers:
                self.selenium = selenium("localhost", 5555, browser,\
                                         configuration.data['site'])
                self.selenium.start()
        elif((len(browsers) == 1) and (browsers[0] in supported_browsers)):
            self.selenium = selenium("localhost", 5555, browsers[0],\
                                         configuration.data['site'])
            self.selenium.start()
        elif((len(browsers) > 1)):
            for browser in browsers:
                if browser in supported_browsers:
                    import pdb;
                    pdb.set_trace()
                    print browser
                    self.selenium = selenium("localhost", 5555, browsers[0],\
                                         configuration.data['site'])
                    self.selenium.start()
        #elif(len(browsers) == 0):
        #    self.selenium = selenium("localhost", 5555, "*firefox",\
        #                                 configuration.data['site'])
        #    self.selenium.start()
        else:
            self.verificationErrors.append("Could not start selenium instance")
Beispiel #3
0
def _start_rc_client(item):
    if item.sauce_labs_credentials_file:
        settings = _get_common_sauce_settings(item)
        settings.update({'username': item.sauce_labs_credentials['username'],
                         'access-key': item.sauce_labs_credentials['api-key'],
                         'os': item.platform,
                         'browser': item.browser_name,
                         'browser-version': item.browser_version})
        TestSetup.selenium = selenium('ondemand.saucelabs.com', '80',
                                      json.dumps(settings),
                                      TestSetup.base_url)
    else:
        browser = item.environment or item.browser
        TestSetup.selenium = selenium(item.host, str(item.port), browser, TestSetup.base_url)

    if item.config.option.capture_network:
        TestSetup.selenium.start("captureNetworkTraffic=true")
    else:
        TestSetup.selenium.start()

    if item.sauce_labs_credentials_file:
        _capture_session_id(item, _debug_path(item))

    TestSetup.selenium.set_timeout(TestSetup.timeout)
    TestSetup.selenium.set_context(".".join(_split_class_and_test_names(item.nodeid)))
    def create(self):
        """
         Uses a driver specified by the 'SELENIUM_DRIVER' environment variable,
         and run the test against the domain specified in 'SELENIUM_URL' system property or the environment variable.
         If no variables exist, a local Selenium driver is created.
        """

        if 'SELENIUM_STARTING_URL' not in os.environ:
            startingUrl = "http://saucelabs.com"
        else:
            startingUrl = os.environ['SELENIUM_STARTING_URL']

        if 'SELENIUM_DRIVER' in os.environ and 'SELENIUM_HOST' in os.environ and 'SELENIUM_PORT' in os.environ:
            parse = ParseSauceURL(os.environ["SELENIUM_DRIVER"])
            driver = selenium(os.environ['SELENIUM_HOST'], os.environ['SELENIUM_PORT'], parse.toJSON(), startingUrl)
            driver.start()

            if parse.getMaxDuration() != 0:
                driver.set_timeout(parse.getMaxDuration())

            wrapper = Wrapper(driver, parse)
            wrapper.dump_session_id()
            return wrapper
        else:
            driver = selenium("localhost", 4444, "*firefox", startingUrl)
            driver.start()
            return driver
Beispiel #5
0
 def setUp(self):
     self.verificationErrors = []
     self.seleniumN = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumN.start()
     self.seleniumE = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumE.start()
     self.seleniumS = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumS.start()
     self.seleniumW = selenium('localhost', 4444, '*firefox', 'http://localhost:8080/')
     self.seleniumW.start()
def shut_down_selenium_server(host='localhost', port=4444):
    """Shuts down the Selenium Server.

    `host` and `port` define where the location of Selenium Server.

    Does not fail even if the Selenium Server is not running.
    """
    try:
        selenium(host, port, '', '').shut_down_selenium_server()
    except socket.error:
        pass
 def sel(self):
     
     if hasattr(self, '_sel'):
         return self._sel
         
     if self.login_mode == 'basic':
         self._sel = selenium(self.sel_host, self.sel_port, self.sel_browser, 
                              'http://%s:%s@%s:%s/'%(self.username, self.password, self.ip, self.port))
     else:
         self._sel = selenium(self.sel_host, self.sel_port, self.sel_browser, 'http://%s/'%self.ip)
     self._sel.start()
     
     return self._sel
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("ondemand.saucelabs.com", 
                              80, 
                              "{\"username\": \"issuu\",\"access-key\":\"23a5b32a-6ab8-4866-8f1d-9a13c98348c2\",\"browser\": \"firefox\",\"browser-version\":\"18\",\"job-name\":\"TestAbout\",\"max-duration\":1800,\"record-video\":true,\"user-extensions-url\":\"\",\"os\":\"Windows 2012\"}", 
                              "http://issuu.com/")
     self.selenium.start()
Beispiel #9
0
def full_scrape(config):
    print("Updating constant entries...")
    update_constants()

    print("Beginning scrape job...")

    # Create a new instance of Selenium
    s = selenium("localhost", 4444, "*chrome", "https://sso.queensu.ca/amserver/UI/Login")
    s.start()
        
    s.set_timeout(config.timeout_milliseconds)

    #save our useful stuff to pass around
    tools = ScraperTools(s, config)

    #get to a browsable state
    login_helper.navigate_to_course_catalog(tools)

    #Go through the pages for each letter in the course catalogue

    for letter in config.subject_letters:
        subject_helper.drill_subjects_for_letter(letter, tools)

    print("Completed scrape job")

    s.stop()
Beispiel #10
0
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*firefox /usr/lib64/firefox-3.6/firefox", "http://localhost/")
        self.selenium.start()

        self.first_user = "******";
        self.second_user = "******";
        self.third_user = "******";
        self.password = "******";
        self.second_logged_in_user_name = "SeleniumSecondUser";
        self.project_name = "SeleniumTestProject";
        self.project_url_name = "seleniumtestproject";
        self.dashboard_suffix = " dashboard - Task Taste";
        self.edited_first_task = "Edited first task"
        self.edited_first_task_again = "Edited first task again"
        self.edited_project_url = "/projects/" + self.third_user + "/" + self.project_url_name;
        self.edited_second_task_size = "42";
        self.edited_project_name = "SeleniumTestProject";
        self.new_task_name = "New task 1, click to edit";
        self.named_task_name = "Named new task";
        self.second_new_task_name = "New task 1, click to edit"; # Same, beause we refresh the page
        self.edited_new_task = "Rename first task so we can create a new one";
        self.second_edited_new_task = "Edited new task";
        self.first_task_name = "First task, click to edit";
        self.second_task_name = "Second task, click to edit";
        self.zero_size = '0';
        self.zeroed_task_name = self.edited_new_task;
        self.default_project_description = "Project description. Click here to edit if you are a logged in project administrator.";
        self.new_project_description = "This is an edited project description";
        self.cancelled_task_name = "Canceled task name text";
Beispiel #11
0
 def setUpHierarchy(browser = "*chrome", 
                    path = "", 
                    ipaddr = "localhost", 
                    ipport = 4444, 
                    webURL = "http://127.0.0.1:8000/"):
     """
         This method would typically only be run once it will create a
         Selenium instance and then start it.
         
         This is a static method with the idea that the properties created
         in this method are shared amongst all subclasses. That is:
         SahanaTest.selenium and SahanaTest.action
     """
     if  (SahanaTest.ipaddr != ipaddr) or (SahanaTest.ipport != ipport) or (SahanaTest.browser != browser) or (SahanaTest.webURL !=  webURL):
         SahanaTest._seleniumCreated = False
     # Only run once
     if not SahanaTest._seleniumCreated:
         if browser == "*custom":
             browser += " %s" % path
         print "selenium %s %s %s %s" % (ipaddr, ipport, browser, webURL)
         SahanaTest.ipaddr = ipaddr
         SahanaTest.ipport = ipport
         SahanaTest.browser = browser
         SahanaTest.webURL =  webURL
         SahanaTest.selenium = selenium(ipaddr, ipport, browser, webURL)
         SahanaTest.action = actions.Action(SahanaTest.selenium)
         SahanaTest._seleniumCreated = True
     if SahanaTest.selenium.sessionId == None:
         SahanaTest.selenium.start()
 def setUp(self):
     self.toolBox = self.getGlbToolbox()
     self.selenium = selenium(
         "localhost", 4444, "*firefox", "https://stage.ariasystems.net/webclients/dreamworksPay/Handler.php"
     )
     self.selenium.start()
     self.selenium.window_maximize()
def get_index():
    '''
        use Selenium to access search result page

        Selenium script is as follows:
            Under "Documents To Search." select Both Under Opportunity/Procurement Type
            Select "Awards"
            Under " Recovery and Reinvestment Act Action." select Yes
    '''
    from selenium import selenium
    sel = selenium("localhost", 4444, "*chrome", "http://fbo.gov/")

    # follow script
    sel.start()
    sel.open("/?s=opportunity&tab=search&mode=list")
    sel.click("dnf_class_values_procurement_notice__procurement_type___a_check")
    sel.click("yui-gen4")
    sel.click("yui-gen5")
    sel.click("//form[@id='vendor_procurement_notice_search']/div/div[3]/input[1]")
    sel.wait_for_page_to_load("30000")

    # hack to avoid dealing with pagination, increase pp to 10000
    sel.open('https://www.fbo.gov/?&s=opportunity&mode=list&tab=searchresults&tabmode=list&pp=10000')

    # get source & turn of server
    html = sel.get_html_source()
    sel.shut_down_selenium_server()
    return html
Beispiel #14
0
    def __init__(self):
        CrawlSpider.__init__(self)
	print "szlibspider start"
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*firefox /usr/lib/firefox/firefox", "http://www.szlib.gov.cn/libraryNetwork/selfLib/id-5.html")
	ffdriver = Firefox()
	self.selenium.start(driver=ffdriver)
#	self.selenium.start()


        sel = self.selenium
#        sel.open("http://www.szlib.gov.cn/libraryNetwork/selfLib/id-5.html")
        ffdriver.get("http://www.szlib.gov.cn/libraryNetwork/selfLib/id-5.html")
	WebDriverWait(ffdriver,30).until(ajax_complete, "Timeout waiting page to load")	

        #Wait for javscript to load in Selenium
#        time.sleep(20)
#	sel.wait_for_condition("condition by js", 20000);
#	print "ul/li visible? %s" % sel.is_element_present("//ul[@class='servicepointlist']")

	elements = ffdriver.find_elements_by_xpath("//ul[@class='servicepointlist']/li[@class='item']")
	for element in elements[:5]:
		print "%s" % element.find_element_by_class_name("num").text
		print "%s" % element.find_element_by_class_name("title").text
		print "%s" % element.find_element_by_class_name("text").text
		print "---------------"
    def getSelenium (self):
        if self.selenium is None:
            if self.host.find(':') >= 0:
                host = self.host.split(':')
                try:
                    self.port = int(host[1])
                    if host[0] != '':
                        self.host = host[0]
                except:
                    pass
            self.selenium = selenium(self.host, self.port, self.browser, self.url)
        self.selenium.start()
        self.selenium.open("/%s" % self.base)
        script = urllib2.urlopen("%s/appmedia/webgateway/js/3rdparty/jquery-1.3.2.js" % (self.url))
        r = script.read()
        self.selenium.run_script(r)
        script.close()
        self.selenium.add_location_strategy("jquery",
'''
  if (inWindow.jQuery.expr[':'].containsExactly === undefined) {
    inWindow.jQuery.expr[':'].containsExactly = function (a,i,m) { return inWindow.jQuery(a).text() == m[3];};
  }
  var found = inWindow.jQuery(inDocument).find(locator);
  if(found.length >= 1 ){
    return found.get(0);
  }else{
    return null;
  }
''')
        return self.selenium
Beispiel #16
0
def get_youtube_video_url(self,vid_format="embed"):
    if "firefox" not in selvars.set_browser():
        youtubeURL = "http://www.youtube.com/watch?v=lVJVRywgmYM"
    else:
        cat_num = random.randint(1,26)
        self.selenium = (selenium(selvars.set_localhost(), selvars.set_port(), selvars.set_browser("youtube"," get video url"), "http://youtube.com/"))
        self.selenium.start()
        vsel= self.selenium
        vsel.set_timeout(testvars.timeout)
        try:       
            if vid_format == "webm":
                vsel.open("results?uploaded=w&search_query=crazy&search_duration=short&webm=1&search_type=videos&uni=3&search_sort=video_date_uploaded")
            else:
                vsel.open("videos?s=mr&c="+str(cat_num))
            vsel.wait_for_page_to_load(testvars.timeout)

            for x in range(0,5):
                time.sleep(2)
#                if vsel.is_element_present("css=div.video-title"): break
                if vsel.is_element_present("css=div.browse-item-content"): break
                cat_num = random.randint(1,26)
                vsel.open("videos?s=mr&c="+str(cat_num))
                vsel.wait_for_page_to_load(testvars.timeout)
                if x == 4:
                    self.fail("can't get youtube video url")
#            vsel.click("css=div.video-title a")         
            vsel.click("css=div.browse-item-content h3 a")         
            vsel.wait_for_page_to_load(testvars.MSTestVariables["TimeOut"])
            youtubeURL = vsel.get_eval("window.location")
            print youtubeURL      

        finally:
            vsel.stop()
    return youtubeURL
Beispiel #17
0
def start_selenium(configuration):
    """Starts Selenium session.

    Arguments:
    configuration - dictionary of Selenium configuration settings.

    Return:
    Selenium instance."""
    # get version
    version = int(configuration['version'])
    # if version is 1, start Selenium RC
    if version == 1:
        s = selenium(configuration['hostname'],
                     configuration['port'],
                     configuration['browser'],
                     configuration['base-url'])
        s.start()
    # if version is 2, start Selenium Webdriver
    elif version == 2:
        # initialize correct browser
        browser = configuration['browser'].lower()
        if browser == 'firefox':
            s = webdriver.Firefox()
        elif browser == 'chrome':
            s = webdriver.Chrome()
        elif browser == 'ie':
            s = webdriver.Ie()
        else:
            error = "Unknown browser. Can't start Webdriver session."
            raise RuntimeError, error
    # otherwise raise error
    else:
        error = 'Selenium version is not set. Check you system.cfg file.'
        raise RuntimeError, error
    return s
Beispiel #18
0
    def __init__(self, proxies={'http': 'http://127.0.0.1:8080',
        'https': 'http://127.0.0.1:8080'}):
        """
        Creates an instance of the ZAP api client.

        :Parameters:
           - `proxies`: dictionary of ZAP proxies to use.
           
        Note that all of the other classes in this directory are generated
        new ones will need to be manually added to this file
        """
        self.__proxies = proxies
        
        self.acsrf = acsrf(self)
        self.ajaxSpider = ajaxSpider(self)
        self.ascan = ascan(self)
        self.authentication = authentication(self)
        self.autoupdate = autoupdate(self)
        self.brk = brk(self)
        self.context = context(self)
        self.core = core(self)
        self.forcedUser = forcedUser(self)
        self.httpsessions = httpSessions(self)
        self.importLogFiles = importLogFiles(self)
        self.params = params(self)
        self.pnh = pnh(self)
        self.pscan = pscan(self)
        self.script = script(self)
        self.search = search(self)
        self.selenium = selenium(self)
        self.sessionManagement = sessionManagement(self)
        self.spider = spider(self)
        self.users = users(self)
Beispiel #19
0
def start_browser(browser, html_out):
    if browser == "chrome":
        # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
        # installing Chrome. Also note that the build bot runs have a different path
        # from a normal user -- check the build logs.
        return selenium.webdriver.Chrome()
    elif browser == "ff":
        profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile()
        profile.set_preference("dom.max_script_run_time", 0)
        profile.set_preference("dom.max_chrome_script_run_time", 0)
        return selenium.webdriver.Firefox(firefox_profile=profile)
    elif browser == "ie" and platform.system() == "Windows":
        return selenium.webdriver.Ie()
    elif browser == "safari" and platform.system() == "Darwin":
        # TODO(efortuna): Ensure our preferences (no pop-up blocking) file is the
        # same (Safari auto-deletes when it has too many "crashes," or in our case,
        # timeouts). Come up with a less hacky way to do this.
        backup_safari_prefs = os.path.dirname(__file__) + "/com.apple.Safari.plist"
        if os.path.exists(backup_safari_prefs):
            shutil.copy(backup_safari_prefs, "/Library/Preferences/com.apple.Safari.plist")
        sel = selenium.selenium("localhost", 4444, "*safari", "file://" + html_out)
        try:
            sel.start()
            return sel
        except socket.error:
            print "ERROR: Could not connect to Selenium RC server. Are you running" + " java -jar selenium-server-standalone-*.jar? If not, start " + "it before running this test."
            sys.exit(1)
    else:
        raise Exception("Incompatible browser and platform combination.")
Beispiel #20
0
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*chrome", settings.test_site)
        self.selenium.start()

        sel = self.selenium

        sel.open("/")
        sel.wait_for_page_to_load(settings.load_timeout)
        
        # open url which clears out the database
        sel.open("/util/cleanup")

        sel.wait_for_page_to_load(settings.load_timeout)
        
        title = sel.get_title()
        print "Page title:%s\n" % title
    
        if ((title == "Google Accounts" ) or (title == "Login")) :
            self.__login__(sel)
         
        self.__check_main_page__(sel)
                    
        self.__load_images__(sel)

        self.__add_players__(sel)
Beispiel #21
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost:8000/")
     self.selenium.start()
     self.selenium.window_maximize()
     #self.selenium.set_speed(200)
     self.app = ClientApp.objects.get_or_create(url='fixtureapp.tmp')[0]
Beispiel #22
0
 def setUp(self):
     # http://saucelabs.com/docs/browsers
     
     self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost:8080/")
     #self.selenium = selenium("localhost", 4444, "*chrome", "http://10.1.1.5:8080/")
     # self.selenium = selenium("localhost", 4444, "*firefox", "http://localhost:8080/")
     self.selenium.start()
Beispiel #23
0
 def setUp(self):
     self.selenium = selenium(ConnectionParameters.server, 
                             ConnectionParameters.port,
                             ConnectionParameters.browser, 
                             ConnectionParameters.baseurl)
     self.selenium.start()
     self.selenium.set_timeout(ConnectionParameters.page_load_timeout)
    def test_validNewInfo(self):
        '''Valid new account information -- TC2'''
        self.selenium = selenium("localhost", 4444, "*firefox", "https://stage.ariasystems.net/webclients/dreamworksPay/Handler.php")
        self.selenium.start()
        self.selenium.window_maximize()
        username, result1 = self.toolBox.registerNewUsername()
        self.assertTrue('user' in result1, "XML from register does not contain user")
        gameAcctId = self.toolBox.getGameIdFromUser(username)
        id = result1['user']['id']
        firstName = 'Tester'
        lastName = 'Dummy'
        billingType = '1'
        address1 = '123 Fake Street'
        city = 'San Mateo'
        state = 'CA'
        country = 'US'
        zipCode = '94403'
        gameUrl = 'http://gazillion.com'
        clientIpAddress = '192.168.1.1'
        result2 = self.toolBox.createBillingAcct(id,gameAcctId,billingType,clientIpAddress,planId='10003936',firstName=firstName,lastName=lastName,
                                                      address1=address1,city=city,state=state,country=country,zipCode=zipCode,gameUrl=gameUrl)
        self.assertTrue('account' in result2, result2)
        billingId = result2['account']['accountId']
        sessionId = result2['account']['inSessionID']
        flowId = result2['account']['flowID']
        self.ariaHostedPage(sessionId, flowId)
        self.selenium.close()
        self.selenium.stop()

        result = self.toolBox.getChildBillingAccounts(id)
        self.assertTrue(result.httpStatus() == 499,\
                        "http status code: " + str(result.httpStatus()))    
        self.failureCheck(result, ['There are no child billing accounts for this user', '16035'])
        self.infoFailCheck(result, id)
        self.toolBox.scriptOutput("getChildBillingAccounts new account structure account", {"Gazillion Id": id, "childBillingAccountId": billingId})
Beispiel #25
0
 def setUp(self):
     """Make the selenium connection"""
     TestCase.setUp(self)
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*firefox",
                              "http://localhost:8000/")
     self.selenium.start()
    def start_rc_client(self):
        self.selenium = selenium(self.host, str(self.port), self.browser, self.base_url)

        if self.capture_network:
            self.selenium.start('captureNetworkTraffic=true')
        else:
            self.selenium.start()
Beispiel #27
0
 def __init__(self):
     self.PAGE_LOAD_TIMEOUT = 1000
     #self.url = 'http://apps.isiknowledge.com'
     self.url = C.START_URL  
     self.br = selenium("localhost", 4444, "*chrome", self.url)
     self.FILE_SAVING_TIME = 1.0   # seconds to wait before attempting to read downloaded files
     self.SKIP_TIME = 0.5    # seconds to wait before re-attempting to read downloaded files
Beispiel #28
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost",
             4444,
             "*chrome",
             "http://localhost:8000/")
     self.selenium.start()
    def __init__(self, host,
                       port,
                       start_cmd,
                       load_timeout,
                       webpage_language,
                       webpage_currency,
                       webpage_usrplace,
                       departure_month,
                       departure_year,
                       output_encoding):

        print('Initializing selenium...')
        
        self.host             = host
        self.port             = port
        self.start_cmd        = start_cmd
        self.load_timeout     = load_timeout
        self.webpage_language = webpage_language
        self.webpage_currency = webpage_currency
        self.webpage_usrplace = webpage_usrplace
        self.departure_month  = departure_month
        self.departure_year   = departure_year
        self.output_encoding  = output_encoding

        self.num_of_flights = -1

        self.browser = selenium(self.host, self.port, self.start_cmd, self.root_url)
Beispiel #30
0
def refreshSelenium() :
  global sel
  if sel :
    sel.stop()
    sel = None
  sel = selenium("localhost", 4444, "*firefox", getWebRoot())
  sel.start()
def make_uspto_browser():
    browser = selenium.selenium('localhost', 4444, '*firefox',
                                'http://portal.uspto.gov')
    browser.start()
    return browser
Beispiel #32
0
 def setUp(self):
     self.selenium = selenium("localhost", \
         4444, "*firefoxproxy", "http://www.w3schools.com")
     self.selenium.start()
Beispiel #33
0
 def setUp(self):
     self.selenium = selenium("localhost", 4444, "*firefox",
                              "http://www.google.com/webhp")
     self.selenium.start()
Beispiel #34
0
 def setUp(self):
     self.selenium = selenium(vars.ConnectionParameters.server, vars.ConnectionParameters.port, vars.ConnectionParameters.browser, vars.ConnectionParameters.baseurl)
     self.selenium.start()
     self.selenium.set_timeout(vars.ConnectionParameters.page_load_timeout)
     self.selenium.open(vars.ConnectionParameters.authurl)
     self.selenium.open(vars.ConnectionParameters.authurlssl)
Beispiel #35
0
 def setUp(self):
     self.selenium = selenium("localhost", 4444, "*mock",
                              "http://localhost:4444")
     self.selenium.start()
     self.selenium.open(
         "http://localhost:4444/selenium-server/tests/html/test_i18n.html")
Beispiel #36
0
 def setUp(self):
     print "Using selenium server at " + self.seleniumHost + ":" + self.seleniumPort
     self.selenium = selenium(self.seleniumHost, self.seleniumPort,
                              self.browserStartCommand, self.browserURL)
     self.selenium.start()
Beispiel #37
0
from selenium import selenium

sel = selenium('localhost', 4444, '*Chrome', 'http://www.baidu.com')

sel.open('/')
sel.type('id = kw', 'selenium grid')
sel.click('id = su')
sel.wait_for_page_to_load('30000')

sel.stop()
Beispiel #38
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", testvars.MCTestVariables["Port"],
                              testvars.MCTestVariables["Browser"],
                              testvars.MCTestVariables["TestSite"])
     self.selenium.start()
Beispiel #39
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*firefox",
                              "http://www.gsmarena.com/")
     self.selenium.start()
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", gSeleniumServerPort, testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
     self.selenium.start()
     self.selenium.set_timeout(testvars.MCTestVariables["TimeOut"])
Beispiel #41
0
 def __init__(self, **kwargs):
     print kwargs
     self.sel = selenium("localhost", 4444, "*firefox",
                         "http://selenium.com/")
     self.sel.start()
Beispiel #42
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome", "http://ws6.test-rig.com:7080")
     self.selenium.start()
Beispiel #43
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from selenium import selenium

sel = selenium("localhost", 4444, "*firefox", "http://www.baidu.com/")
sel.start()

sel.open("/")
sel.type("id=kw", "selenium grid")
sel.click("id=su")
sel.wait_for_page_to_load("30000")

sel.stop()

# (C:\Users\Han\Anaconda3) C:\Users\Han\selenium_test\ch09>python sel_rc.py
# Traceback (most recent call last):
# File "sel_rc.py", line 3, in <module>
# from selenium import selenium
# ImportError: cannot import name 'selenium'

# https://www.seleniumhq.org/download/

# Selenium 3.X is no longer capable of running Selenium RC directly, rather it does it through emulation and the WebDriverBackedSelenium interface.

# Download version 3.11.0

# https://stackoverflow.com/questions/45577940/selenium-module-calling-error

# Update

# You are using Selenium's version 3.+
Beispiel #44
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome",
                              "http://localhost:8000/")
     self.selenium.start()
Beispiel #45
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome",
                              "http://172.31.0.222:9682/")
     self.selenium.start()
Beispiel #46
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium(*self.browser)
     self.selenium.start()
 def setUp(self):
     self.selenium = selenium(vars.ConnectionParameters.server,
                              vars.ConnectionParameters.port,
                              vars.ConnectionParameters.browser,
                              'https://support.mozilla.com')
     self.selenium.start()
Beispiel #48
0
 def __init__(self):
     CrawlSpider.__init__(self)
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome",
                              "http://www.domain.com")
     self.selenium.start()
# Download Selenium 2 and run its remote backend:
#   java -jar selenium-server-standalone-2.0b1.jar 
# Install Python bindings (docs here: http://pypi.python.org/pypi/selenium/2.0-dev)
#   pip install -U selenium

# TODO:
# Make sure it kills any left over sessions somehow. See:
# http://stackoverflow.com/questions/1317844/how-to-close-a-browser-on-a-selenium-rc-server-which-lost-its-client
# Maybe just brutally kill any long running firefox processes?

import sys
from selenium import selenium

# Don't try google-chrome, doesn't work: http://jira.openqa.org/browse/SRC-740
s = selenium("localhost", 4444, "*firefox", "http://localhost/")
s.start()

# Demonstrate it on a fancy ASP example with Javascript
s.open("http://recognition.ncqa.org/PSearchResults.aspx?state=NY&rp=")

while 1:
    # Print page number we are on
    s.wait_for_page_to_load(30000) # timeout in milliseconds
    print s.get_text("css=//span[id=ProviderSearchResultsTable1_lblPhysicianCount]")

    # Can save source here or use in BeautifulSoup etc. - can't work out how to
    # loop over elements in Selenium, even Selenium 2. Answers here might help:
    # http://stackoverflow.com/questions/3943997/get-text-from-all-elements-matching-a-pattern-in-selenium
    # s.get_html_source()
Beispiel #50
0
import pyautogui
import ConfigParser
import win32clipboard
import win32com.client
import pyscreenshot as ImageGrab
from network import SCP
from selenium import selenium
from android import Android
from android import AdbClient
from delete_subfolder import Delete_Subfolder

config_element = ConfigParser.ConfigParser()
config_element.read(".\..\\..\\ini\\web_control_element.conf")
config_setting = ConfigParser.ConfigParser()
config_setting.read(".\..\\..\\ini\\web_control_setting.conf")
selenium = selenium("localhost", config_setting.get("setting", "port"), "*iexplore",
					"http://" + config_setting.get("setting", "ip_address") + ":8082/CWMServer/")
autoit = win32com.client.Dispatch("AutoItX3.Control")


class Webcontrol(object):

	###################  main menu  ####################
	def Initial(self):
		try:
			os.system(config_element.get("setting", "cancel_msta"))
			selenium.start()
			selenium.open("/CWMServer/index.jsp")
			selenium.window_maximize()
			print "The screen was open - PASS"
		except:
			raise Exception("The screen was not open - FAIL")
Beispiel #51
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome", "http://www.baidu.com/")
     self.selenium.start()
Beispiel #52
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome", "https://www.google.fr/")
     self.selenium.start()
Beispiel #53
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*chrome", test_base_url)
     self.selenium.start()
 def test_connfu-selenium(self):
     sel = self.selenium
Beispiel #55
0
    def test_selenium_export(self):

        #Check if we're just crunching data
        if self.should_read_from_file:
            self.read_from_file()
            self.optimize_data()
            return

        #If not... off we go scraping!
        print "Setting up Selenium..."

        self.selenium = selenium("localhost", 4444, "*chrome",
                                 "https://sso.queensu.ca/amserver/UI/Login")
        self.selenium.start()

        self.selenium.set_timeout(self.timeout_milliseconds)

        print "Opening login page..."

        sel = self.selenium
        sel.open("/amserver/UI/Login")

        #Get login information from config file
        with open('../ignored_files/selenium_config.txt', 'r') as config_file:
            line_num = 0
            login_info = ['', '']
            for line in config_file:
                login_info[line_num] = line.strip()
                line_num += 1

        #Enter Credentials
        sel.type("id=IDToken1", login_info[0])
        sel.type("id=IDToken2", login_info[1])

        #Log in
        print "Logging in..."
        sel.click("name=Login.Submit")
        sel.wait_for_page_to_load(self.timeout_milliseconds)

        #Get URL for SOLUS and open it
        print "Opening SOLUS..."
        solus_url = sel.get_attribute("link=SOLUS Student Centre@href")
        sel.open(solus_url)

        #Get to content frame
        sel.select_frame("name=TargetContent")

        #"Search For Classes"
        print "Navigating to \"Search For Classes\"..."
        sel.click("id=DERIVED_SSS_SCL_SSS_GO_4$230$")
        sel.wait_for_page_to_load(self.timeout_milliseconds)

        #"browse course catalog"
        print "Navigating to \"browse course catalog\"..."
        sel.click("link=browse course catalog")
        sel.wait_for_page_to_load(self.timeout_milliseconds)

        print "Navigation to SOLUS complete. Beginning scraping..."

        #Go through all the course catalogue pages

        for alphanum in self.alphanums:
            self.scrape_subjects_for_alphanum(alphanum)

        self.selenium.stop()

        print "\nScraped a total of:"
        print "%d Subjects" % len(SolusModels.Subject.subjects)
        print "%d Courses" % SolusModels.SolusCourse.num_courses
        print "%d Section Types" % len(SolusModels.SectionType.section_types)
        print "%d Terms" % len(SolusModels.Term.terms)
        print "%d Timeslots" % len(SolusModels.Timeslot.timeslots)

        print "\nUnique Attributes were:"

        for key in self.unique_attributes:
            print "(%s): %s" % (self.unique_attributes[key], key)

        #for course in self.courses:
        #course.describe()

        self.optimize_data()

        self.write_json()
Beispiel #56
0
# -*- coding: utf-8 -*-
from selenium import selenium

sel = selenium("192.168.1.8", 4444, "*firefox","https://www.bing.com/")
sel.start()

##sel = selenium
## driver.implicitly_wait(30)
base_url = "https://www.bing.com/"
verificationErrors = []
accept_next_alert = True


sel.open("/")
##sel.type("q", "selenium rc")
##sel.click("btnG")
##sel.wait_for_page_to_load("30000")
##print(sel.is_text_present("Results * for selenium rc"))
##selenium.stop()

        
##driver.get("https://www.bing.com/")
##driver.find_element_by_id("sb_form_q").click()
##driver.find_element_by_id("sb_form_q").clear()
##driver.find_element_by_id("sb_form_q").send_keys("SELENIUM")
##driver.find_element_by_id("sb_form_q").send_keys(Keys.ENTER)
##driver.find_element_by_id("sb_form_go").click()
##driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='Selenium'])[3]/following::div[2]").click()
##driver.quit()
##assertEqual([], verificationErrors)
##driver.close()
Beispiel #57
0
    def __init__(self, aUseWebDriver, aUseGrid,
                 aHost, aPort, aMathJaxPath, aMathJaxTestPath,
                 aOperatingSystem,
                 aBrowser,
                 aBrowserVersion,
                 aBrowserMode,
                 aBrowserPath,
                 aFont,
                 aOutputJax,
                 aTimeOut,
                 aFullScreenMode):
        """
        @fn __init__(self, aUseWebDriver, aUseGrid,
                     aHost, aPort, aMathJaxPath, aMathJaxTestPath,
                     aOperatingSystem,
                     aBrowser,
                     aBrowserVersion,
                     aBrowserMode,
                     aBrowserPath, 
                     aFont,
                     aOutputJax,
                     aTimeOut,
                     aFullScreenMode)

        @param aUseWebDriver Whether to use Selenium 2 (Webdriver)
        @param aUseGrid Whether we use grid. In that case, requests are not
        sent directly to the Selenium server on the host machine, but to
        the Selenium Hub.
        @param aHost Value to assign to @ref mHost
        @param aPort Value to assign to @ref mPort
        @param aMathJaxPath Value to assign to @ref mMathJaxPath
        @param aMathJaxTestPath Value to assign to @ref mMathJaxTestPath
        @param aOperatingSystem Value to assign to @ref mOperatingSystem
        @param aBrowser Value to assign to @ref mBrowser
        @param aBrowserVersion Value to assign to @ref mBrowserVersion
        @param aBrowserMode Value to assign to @ref mBrowserMode
        @param aBrowserPath Path to the browser executable, or "default".
        @param aFont Value to assign to @ref mFont
        @param aOutputJax Value to assign to @ref mOutputJax
        @param aTimeOut Value to assign to @ref mTimeOut
        @param aFullScreenMode Value to assign to @ref mFullScreenMode

        @see http://devel.mathjax.org/testing/web/docs/html/components.html#test-runner-config

        @property mHost
        Host of the Selenium server
        @property mPort
        Port of the Selenium server
        @property mMathJaxPath
        URI of a MathJax installation
        @property mMathJaxTestPath
        URI of a testsuite
        @property mOperatingSystem
        Operating system of the test machine
        @property mBrowser
        Name of the browser to run
        @property mBrowserVersion
        Version of the browser to run
        @property mBrowserMode
        Browser mode for Internet Explorer
        @property mFont
        font to use: STIX, TeX, ImageTeX
        @property mOutputJax
        output Jax to use: HTML-CSS, SVG, NativeMML
        @property mTimeOut
        time allowed before aborting a test
        @property mFullScreenMode
        whether the browser should be put in full screen mode, when possible
        @property mCanvas
        A 4-tuple defining the left, upper, right, and lower pixel coordinate
        of the area to capture. Assumed to be of size at most mReftestSize.
        @property mReftestSize
        The dimension of reftest images. It is set to 800x1000 px, to follow
        the size of screenshots used by Mozilla
        """
        self.mHost = aHost
        self.mPort = aPort
        self.mMathJaxPath = aMathJaxPath
        self.mMathJaxTestPath = aMathJaxTestPath
        self.mOperatingSystem = aOperatingSystem
        self.mBrowser = aBrowser
        self.mBrowserVersion = aBrowserVersion
        self.mBrowserMode = aBrowserMode
        self.mFont = aFont
        self.mOutputJax = aOutputJax
        self.mTimeOut = aTimeOut
        self.mFullScreenMode = aFullScreenMode

        self.mCanvas = None
        self.mReftestSize = (800, 1000)

        if (aUseGrid):
            host = SELENIUM_SERVER_HUB_HOST
            port = SELENIUM_SERVER_HUB_PORT
        else:
            host = aHost
            port = aPort

        if (aUseGrid or aUseWebDriver):
            if aBrowser == "Firefox":
                desiredCapabilities = webdriver.DesiredCapabilities.FIREFOX
            elif aBrowser == "Chrome":
                desiredCapabilities = webdriver.DesiredCapabilities.CHROME
            elif aOperatingSystem == "Windows" and aBrowser == "MSIE":
                desiredCapabilities = \
                    webdriver.DesiredCapabilities.INTERNETEXPLORER
            elif aBrowser == "Opera":
                desiredCapabilities = webdriver.DesiredCapabilities.OPERA
            elif aBrowser == "HTMLUnit":
                desiredCapabilities = \
                    webdriver.DesiredCapabilities.HTMLUNITWITHJS
            elif aBrowser == "PhantomJS":
                desiredCapabilities = webdriver.DesiredCapabilities.PHANTOMJS
            elif aOperatingSystem == "Mac" and aBrowser == "iPhone":
                desiredCapabilities = webdriver.DesiredCapabilities.IPHONE
            elif aOperatingSystem == "Mac" and aBrowser == "iPad":
                desiredCapabilities = webdriver.DesiredCapabilities.IPAD
            elif aOperatingSystem == "Linux" and aBrowser == "Android":
                desiredCapabilities = webdriver.DesiredCapabilities.ANDROID
            elif ((aOperatingSystem == "Windows" or
                   aOperatingSystem == "Mac") and aBrowser == "Safari"):
                desiredCapabilities = webdriver.DesiredCapabilities.SAFARI
            else:
                raise Exception("Webdriver: OS/browser not available")

            desiredCapabilities["platform"] = aOperatingSystem.upper()

            if aBrowserVersion == "default":
                desiredCapabilities["version"] = ""
            else:
                desiredCapabilities["version"] = aBrowserVersion

            if aBrowserPath != "default":
                # TODO: add support for other browsers
                if aBrowser == "Chrome":
                    desiredCapabilities["chrome.binary"] = aBrowserPath
                else:
                    raise Exception("Webdriver: browserPath is not supported")

            self.mWebDriver = webdriver.Remote("http://" + host + ":" +
                                               str(port) + "/wd/hub",
                                               desiredCapabilities)
            self.mWebDriver.implicitly_wait(aTimeOut / 1000)
            self.mWebDriver.set_script_timeout(aTimeOut / 1000)
            self.mSelenium = selenium(host, port, '*webdriver',
                                      aMathJaxTestPath)
            self.mCanvas = 0, 0, self.mReftestSize[0], self.mReftestSize[1]
        else:
            self.mWebDriver = None
            if aBrowser == "Firefox":
                startCommand = "*firefox"
            elif (aOperatingSystem == "Windows" or
                  aOperatingSystem == "Mac") and aBrowser == "Safari":
                startCommand = "*safariproxy"
            elif aBrowser == "Chrome":
                startCommand = "*googlechrome"
            elif aBrowser == "Opera":
                startCommand = "*opera"
            elif aOperatingSystem == "Windows" and aBrowser == "MSIE":
                startCommand = "*iexploreproxy"
            elif aOperatingSystem == "Linux" and aBrowser == "Konqueror":
                startCommand = "*konqueror"
            else:
                startCommand = "*custom"
                
            if aBrowserVersion != "default":
                raise Exception("Selenium 1: browserVersion is not supported")

            if aBrowserPath == "default":
                if startCommand == "*custom":
                    raise Exception("Selenium 1: OS/browser not available ")
      
                # XXXfred: support for Konqueror is broken
                if aOperatingSystem == "Linux" and aBrowser == "Konqueror":
                    startCommand = startCommand + " /usr/bin/konqueror" 
            else:
                startCommand = startCommand + " " + aBrowserPath
              
            self.mSelenium = selenium(host, port, startCommand,
                                      aMathJaxTestPath)
Beispiel #58
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("52.170.81.120", 4444, "*chrome", "https://mpnesp.learnondemand.net")
     self.selenium.start()
Beispiel #59
0
 def __init__(self):
     CrawlSpider.__init__(self)
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*firefox",
                              "http://www.jb51.net")
     self.selenium.start()
 def setUp(self):
     self.makeConfigStrings()
     self.loadCredentials()
     self.verificationErrors = []
     self.selenium = selenium(credentials.seleniumHost, credentials.seleniumPort, "*firefox", credentials.seleniumBaseURL)
     self.selenium.start()