working on it ...

Filters

Explore Public Snippets

Sort by

Found 143 snippets matching: "web test"

    public by lbottaro  11094  5  10  4

    Dalekjs - Simple automated web test

    This snippet is a simple test for web page using Dalekjs testing tool. Here I import functions from a 'functions' file (placed in the same dir of this file, called functions.js). The test will execute three tests, 'Snip2code footer', 'LogOut' and 'Sign Up'. More info about dalekjs tool here Site: dalekjs.com
    //var S2CSettings = require('s2c_settings');
    var S2Cfns = require('./s2c_functions');
    var domain = "http://www.snip2code.com/"
    var appName = "Snip2Code"
    
    module.exports = {
    'Snip2code footer': function (test) {
      test
    	.open(domain)
    	.assert.url(domain, 'URL is as expected')
        .assert.title().is('Snip2Code', 'It has title')
    	.assert.exists('a[href="/Static/ToS"]', 'ToS exists')
    	.assert.exists('a[href="/Static/Privacy"]', 'Privacy exists')
    	.assert.exists('a[href="/Static/AboutUs"]', 'AboutUs exists')
    	.assert.exists('a[href="mailto:info@snip2code.com"]', 'Mailto exists')
    	.assert.exists('a[href="/Static/Downloads"]', 'Downloads exists')
    	.assert.exists('a[href="http://blog.snip2code.com"]', 'Blog exists')
    	.assert.exists('a[href="/Static/Docs"]', 'API exists')
        .done();
    },
    'Logout': S2Cfns.S2CLogout.bind(S2Cfns, domain),
    'Sign Up': function (test) {
      test
    	.open(domain)
    	.click('#signupBigBt')
    	.assert.title().is('Snip2Code - Sign Up', 'Sign Up is loaded')
    	.assert.url().to.contain(domain + 'Access/Signup', 'URL is as expected')
    	.type('#EMail', 'email@test.com')
    	.type('#Username', 'Pinkman')
    	.type('#Password', 'Walt')
    	.wait(5000)
        .done();
    }
    };  

    public by sukhjinderkahlon  6509  35  6  0

    Extent Report For Selenium Java

    This code will work with Extent Report Utility for Java, Selenium, TestNG.
    //Download Jars from below website
    //http://relevantcodes.com/extentreports-for-selenium/
    import java.io.File;
    import java.io.IOException;
    
    import org.apache.commons.io.FileUtils;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.TakesScreenshot;
    import org.openqa.selenium.WebDriver;
    
    import com.relevantcodes.extentreports.DisplayOrder;
    import com.relevantcodes.extentreports.ExtentReports;
    
    	public class ReportFactory {
    		private static ExtentReports reporter;
    		
    		
    		public static ExtentReports getReporter() {
    			if (reporter == null) {
    				reporter = new ExtentReports("Report.html", true, DisplayOrder.NEWEST_FIRST);
    			}
    			return reporter;
    		}
    				
    		
    		//Close Reporter
    		
    		public static void closeReporter() {
    			if (reporter != null) {
    				reporter.flush();
    				reporter.close();
    			}
    		}
    		
    		//Capture ScreenShot
    		public static String CaptureScreen(WebDriver driver, String ImagesPath)
    		{
    		    TakesScreenshot oScn = (TakesScreenshot) driver;
    		    File oScnShot = oScn.getScreenshotAs(OutputType.FILE);
    		 File oDest = new File(ImagesPath+".jpg");
    		 try {
    		      FileUtils.copyFile(oScnShot, oDest);
    		 } catch (IOException e) {System.out.println(e.getMessage());}
    		 return ImagesPath+".jpg";
    		        }
    		
    		
    
    	}//End of class
    
    
    
    //Using of Extent in TestNG
    import org.testng.annotations.AfterSuite;
    import org.testng.annotations.Test;
    
    import com.relevantcodes.extentreports.ExtentReports;
    import com.relevantcodes.extentreports.ExtentTest;
    import com.relevantcodes.extentreports.LogStatus;
    
    import Damco.Project.ReportFactory;
    
    
    
    public class NewTest {
    	
    	
    private ExtentReports reporter =  ReportFactory.getReporter();
    private boolean status;
    	
    	@Test
    	public void Login()
    	{
    		ExtentTest testReporter = reporter.startTest(this.getClass().getSimpleName()+ " Login", "This is a simple simpleTest001");
    		testReporter.log(LogStatus.INFO, "Starting test simpleTest001");
    		int a = 100;
    		int b = 30;
    		status=false;
    		if(status ){
    		testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
    		testReporter.log(LogStatus.PASS, "Loading the value of b to " + b);
    		
    		}
    		else{
    			testReporter.log(LogStatus.INFO, "Failed to Loading the value of a to " + a);
    			testReporter.log(LogStatus.FAIL, "FAILED due some reason" + b);
    			
    			}
    		reporter.endTest(testReporter);
    	}
    
    	@Test
    	public void simpleTest002()
    	{
    		ExtentTest testReporter = reporter.startTest("simpleTest002", "This is a simple simpleTest001");
    		testReporter.log(LogStatus.INFO, "Starting test simpleTest002");
    		int a = 100;
    		int b = 30;
    
    		testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
    		testReporter.log(LogStatus.PASS, "Loading the value of b to " + b);
    		reporter.endTest(testReporter);
    		
    	}
    	
    	@Test
    	public void Register() throws Exception
    	{
    		ExtentTest testReporter = reporter.startTest("Register", "This is a simple simpleTest001");
    		testReporter.log(LogStatus.INFO, "Starting test simpleTest002");
    		int a = 100;
    		int b = 30;
    
    		testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
    		testReporter.log(LogStatus.PASS, "Loading the value of b to " + b);
    		reporter.endTest(testReporter);
    		
    
    		
    		
    	}
    	
    	
    	@AfterSuite
    	public void afterSuite()
    	{
    		reporter.close();
    	}
    	
    	
    }
    
    
    

    external by Github  589  2  3  0

    Test web2py redirection with py.test and http://github.com/viniciusban/web2py.test

    Test web2py redirection with py.test and http://github.com/viniciusban/web2py.test: test_redirection.py
    # Important: this example counts on the environment created
    # by http://github.com/viniciusban/web2py.test project.
    
    
    ## -----------------------------------
    ## My test case
    
    import sys
    
    def test_redirection(web2py):
        # Calls action_one.
        with pytest.raises(HTTP) as e:
            result = run_controller_in("my_controller", "action_one", web2py)
    
        # Get exception information.
        (_type, _redirection, _traceback) = sys.exc_info()
    
        # Asserts redirection was made to action_two.
        assert _redirection.headers["Location"].split("/")[-1] == "action_two"
    
    
    ## -----------------------------------
    ## My controller under test
    
    def action_one():
        # some code here...
        redirect(URL(f="action_two"))
    
    
    def action_two():
        return dict(message="I'm the second action.")
    
    

    external by Roy Guo  760  0  3  0

    WebGL-Test. index.html里是shader,buffers.js里是所有的物体

    WebGL-Test. index.html里是shader,buffers.js里是所有的物体: buffers.js index.html main.js shaders.js utils.js
    /**
     * Global variables:
     *  	bgVertexBuffer
     *		trianglesVertexBuffer
     *		cubeVertexBuffer
     *		cubeIndexBuffer
     */
    function initBuffers() {
      // bg
      bgVertexBuffer = gl.createBuffer();
      // bind current buffer for further operations.
      gl.bindBuffer(gl.ARRAY_BUFFER, bgVertexBuffer);
      var vertices = [
       2.0,  2.0,  0.0,
      -2.0,  2.0,  0.0,
       2.0, -2.0,  0.0,
      -2.0, -2.0,  0.0
      ];
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
      bgVertexBuffer.itemSize = 3;
      bgVertexBuffer.numItems = 4;
    
      bgVertexColorBuffer = gl.createBuffer();
      gl.bindBuffer(gl.ARRAY_BUFFER, bgVertexColorBuffer);
      var colors = [
        0.0, 1.0, 1.0, 1,
        1.0, 0.0, 1.0, 1,
        0.0, 0.0, 1.0, 1,
        0.0, 0.0, 0.0, 1
      ];
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);
      bgVertexColorBuffer.itemSize = 4;
      bgVertexColorBuffer.numItems = 4;
    
      // Triangle
      trianglesVertexBuffer = gl.createBuffer();
      // bind current buffer for further operations.
      gl.bindBuffer(gl.ARRAY_BUFFER, trianglesVertexBuffer);
      vertices = [
        0.0,  0.5,  0.0,
       -0.5, -0.5,  0.0,
        0.5, -0.5,  0.0
      ];
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
      trianglesVertexBuffer.numItems = 3;
      trianglesVertexBuffer.itemSize = 3;
    
      triangleVertexColorBuffer = gl.createBuffer();
      gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer);
      colors = [
          1.0, 0.0, 0.0, 0.0,
          0.0, 1.0, 0.0, 0.0,
          0.0, 0.0, 1.0, 0.0
      ];
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);
      triangleVertexColorBuffer.itemSize = 4;
      triangleVertexColorBuffer.numItems = 3;
    
      // Cube
      cubeVertexBuffer = gl.createBuffer();
      gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexBuffer);
      vertices = [
          // Front face
          -1.0, -1.0,  1.0,
           1.0, -1.0,  1.0,
           1.0,  1.0,  1.0,
          -1.0,  1.0,  1.0,
    
          // Back face
          -1.0, -1.0, -1.0,
          -1.0,  1.0, -1.0,
           1.0,  1.0, -1.0,
           1.0, -1.0, -1.0,
    
          // Top face
          -1.0,  1.0, -1.0,
          -1.0,  1.0,  1.0,
           1.0,  1.0,  1.0,
           1.0,  1.0, -1.0,
    
          // Bottom face
          -1.0, -1.0, -1.0,
           1.0, -1.0, -1.0,
           1.0, -1.0,  1.0,
          -1.0, -1.0,  1.0,
    
          // Right face
           1.0, -1.0, -1.0,
           1.0,  1.0, -1.0,
           1.0,  1.0,  1.0,
           1.0, -1.0,  1.0,
    
          // Left face
          -1.0, -1.0, -1.0,
          -1.0, -1.0,  1.0,
          -1.0,  1.0,  1.0,
          -1.0,  1.0, -1.0
      ];
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
      cubeVertexBuffer.itemSize = 3;
      cubeVertexBuffer.numItems = 24;
    
      cubeVertexColorBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexColorBuffer);
        colors = [
            [1.0, 0.0, 0.0, 1.0], // Front face
            [1.0, 1.0, 0.0, 1.0], // Back face
            [0.0, 1.0, 0.0, 1.0], // Top face
            [1.0, 0.5, 0.5, 1.0], // Bottom face
            [1.0, 0.0, 1.0, 1.0], // Right face
            [0.0, 0.0, 1.0, 1.0]  // Left face
        ];
        var unpackedColors = [];
        for (var i in colors) {
            var color = colors[i];
            for (var j=0; j < 4; j++) {
                unpackedColors = unpackedColors.concat(color);
            }
        }
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(unpackedColors), gl.STATIC_DRAW);
        cubeVertexColorBuffer.itemSize = 4;
        cubeVertexColorBuffer.numItems = 24;
        // Square vertex index.
        cubeIndexBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeIndexBuffer);
        var cubeVertexIndices = [
            0,  1,  2,    0,  2,  3,    // Front face
            4,  5,  6,    4,  6,  7,    // Back face
            8,  9,  10,   8,  10, 11,   // Top face
            12, 13, 14,   12, 14, 15,   // Bottom face
            16, 17, 18,   16, 18, 19,   // Right face
            20, 21, 22,   20, 22, 23    // Left face
        ];
        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(cubeVertexIndices), gl.STATIC_DRAW);
        cubeIndexBuffer.itemSize = 1;
        cubeIndexBuffer.numItems = 36;
    }
    
    <!DOCTYPE html>
    <html>
      <head>
        <title>Hello World</title>
        <script type="text/javascript" src="Oak3D_v_0_5_9_Debug.js"></script>
        <script type="text/javascript" src="utils.js"></script>
        <script type="text/javascript" src="buffers.js"></script>
        <script type="text/javascript" src="shaders.js"></script>
        <script type="text/javascript" src="main.js"></script>
    
        <script id="shader-fs" type="x-shader/x-fragment">
            precision mediump float;
            varying vec4 vColor;
    
            void main(void) {
                gl_FragColor = vColor;
            }
        </script>
    
        <script id="shader-fs-alpha" type="x-shader/x-fragment">
            precision mediump float;
            varying vec4 vColor;
    
            void main(void) {
              if( gl_FragCoord.x < 350.0 && gl_FragCoord.x > 300.0
                && gl_FragCoord.y < 300.0 && gl_FragCoord.y > 230.0
                ) {
                gl_FragColor = vec4(0, 0 ,0, 0.0);
              } else {
                gl_FragColor = vec4(vColor.rgb, 1.0);
              }
              
            }
        </script>
    
        <script id="shader-vs" type="x-shader/x-vertex">
            attribute vec3 aVertexPosition;
            attribute vec4 aVertexColor;
            // attribute float type;
    
            uniform mat4 uMVMatrix;
            uniform mat4 uPMatrix;
    
            varying vec4 vColor;
    
            void main(void) {
              gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
              vColor = aVertexColor;
              // if(type > 0.0) {
    
              // }
            }
        </script>
    
        <script id="shader-vs-alpha" type="x-shader/x-vertex">
            attribute vec3 aVertexPosition;
            attribute vec4 aVertexColor;
    
            uniform mat4 uMVMatrix;
            uniform mat4 uPMatrix;
    
            varying vec4 vColor;
    
            void main(void) {
              gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
              if(gl_Position.x > -2.0 && gl_Position.x < 2.0) {
                vColor = vec4(aVertexColor.rgb, 0.0);
              } else {
                vColor = vec4(aVertexColor.rgb, 1.0);
              }
            }
        </script>
      </head>
      <body onload = "webGLStart();">
        <canvas id="canvas" style="border: none;" width="500" height="500"></canvas>
      </body>
    </html>
    
    var gl;
    var shaderProgram;
    
    // Objects
    var bgVertexBuffer;
    var bgVertexColorBuffer;
    
    var trianglesVertexBuffer;
    var triangleVertexColorBuffer;
    
    var cubeVertexBuffer;
    var cubeVertexColorBuffer;
    var cubeIndexBuffer;
    
    var mvMatrix ;
    var mvMatrixStack = [];
    var pMatrix ;
    
    
    function drawScene() {
      gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
      gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
      pMatrix = okMat4Proj(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0);
    
      // bg
      mvMatrix = okMat4Trans(0, 0, -8.0);
    
      gl.bindBuffer(gl.ARRAY_BUFFER, bgVertexBuffer);
      gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute,  bgVertexBuffer.itemSize,  gl.FLOAT, false, 0, 0);
    
      gl.bindBuffer(gl.ARRAY_BUFFER, bgVertexColorBuffer);
      gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, bgVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
    
    
      setMatrixUniforms();
      gl.drawArrays(gl.TRIANGLE_STRIP, 0, bgVertexBuffer.numItems);
    
      // Triangle
      mvMatrix = okMat4Trans(0.5, 0, -5.0);
      // bind current buffer for further operations.
      gl.bindBuffer(gl.ARRAY_BUFFER, trianglesVertexBuffer);
      gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, trianglesVertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
    
      gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer);
      gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, triangleVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
    
      setMatrixUniforms();
      // gl.drawArrays(gl.TRIANGLES, 0, trianglesVertexBuffer.numItems);
    
      
      // The cube
      shaderProgram = initShaderAlpha(gl);
      mvMatrix = okMat4Trans(0.5, 0, -7.0);
      // Cube rotation
      mvMatrix.rotY(OAK.SPACE_LOCAL, 10, true);
      mvMatrix.rotX(OAK.SPACE_LOCAL, 30, true);
    
      gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexBuffer);
      gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, cubeVertexBuffer.itemSize,  gl.FLOAT, false, 0, 0);
    
      gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexColorBuffer);
      gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, cubeVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
    
      gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeIndexBuffer);  // Cube needs position index.
      setMatrixUniforms();
      gl.drawElements(gl.TRIANGLES, cubeIndexBuffer.numItems, gl.UNSIGNED_SHORT, 0);
    
      // shaderProgram = initShader(gl);
    }
    
    
    function webGLStart() {
      var canvas = document.getElementById('canvas');
      initGL(canvas);
      initBuffers();
    
      gl.clearColor(0, 0, 0, 0.0);
      gl.enable(gl.DEPTH_TEST);
      // this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE);
      // this.gl.enable(this.gl.BLEND);
      // this.gl.disable(this.gl.DEPTH_TEST);
    
      shaderProgram = initShader(gl);
      drawScene();
    }
    
    /**
     * 
     * 
     */
    function initShader(gl) {
      var fragmentShader = getShader(gl, "shader-fs");
      var vertexShader = getShader(gl, "shader-vs");
    
      var shaderProgram = gl.createProgram();
    
      gl.attachShader(shaderProgram, vertexShader);
      gl.attachShader(shaderProgram, fragmentShader);
      gl.linkProgram(shaderProgram);
    
      if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
          alert("Could not initialise shaders");
      }
      gl.useProgram(shaderProgram);
    
      shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
      gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);
    
      shaderProgram.vertexColorAttribute = gl.getAttribLocation(shaderProgram, "aVertexColor");
      gl.enableVertexAttribArray(shaderProgram.vertexColorAttribute);
    
      // shaderProgram.objectTypeAttribute = gl.getAttribLocation(shaderProgram, "type");
      // gl.enableVertexAttribArray(shaderProgram.objectTypeAttribute);
    
      shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "uPMatrix");
      shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
    
      return shaderProgram;
    }
    
    function initShaderAlpha(gl) {
      var fragmentShader = getShader(gl, "shader-fs-alpha");
      var vertexShaderAlpha = getShader(gl, "shader-vs");
    
      var shaderProgram = gl.createProgram();
    
      gl.attachShader(shaderProgram, vertexShaderAlpha);
      gl.attachShader(shaderProgram, fragmentShader);
      gl.linkProgram(shaderProgram);
    
      if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
          alert("Could not initialise shaders");
      }
      gl.useProgram(shaderProgram);
    
      shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
      gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);
    
      shaderProgram.vertexColorAttribute = gl.getAttribLocation(shaderProgram, "aVertexColor");
      gl.enableVertexAttribArray(shaderProgram.vertexColorAttribute);
    
      // shaderProgram.objectTypeAttribute = gl.getAttribLocation(shaderProgram, "type");
      // gl.enableVertexAttribArray(shaderProgram.objectTypeAttribute);
    
      shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "uPMatrix");
      shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
    
      return shaderProgram;
    }
    
    function setMatrixUniforms() {
      gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix.toArray());
      gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix.toArray());
    }
    
    function initGL(canvas) {
      gl = canvas.getContext("experimental-webgl");
      gl.viewportWidth = canvas.width;
      gl.viewportHeight = canvas.height;
      if(!gl) {
        alert("couldn't init webGL !");
      }
    }
    
    function mvPushMatrix() {
        var copy = new okMat4();
        mvMatrix.clone(copy);
        mvMatrixStack.push(copy);
    }
    
    function mvPopMatrix() {
        if (mvMatrixStack.length == 0) {
            throw "Invalid popMatrix!";
        }
        mvMatrix = mvMatrixStack.pop();
    }
    
    
    function getShader(gl, id) {
      var shaderScript = document.getElementById(id);
      if (!shaderScript) {
          return null;
      }
      var str = "";
      var k = shaderScript.firstChild;
      while (k) {
          if (k.nodeType == 3) {
              str += k.textContent;
          }
          k = k.nextSibling;
      }
    
      var shader;
      if (shaderScript.type == "x-shader/x-fragment") {
          shader = gl.createShader(gl.FRAGMENT_SHADER);
      } else if (shaderScript.type == "x-shader/x-vertex") {
          shader = gl.createShader(gl.VERTEX_SHADER);
      } else {
          return null;
      }
    
      gl.shaderSource(shader, str);
      gl.compileShader(shader);
    
      if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
          alert(gl.getShaderInfoLog(shader));
          return null;
      }
    
      return shader;
    }
    
    
    
    

    external by torarnv  483  1  3  0

    WebCal-test

    WebCal-test: index.html
    <a href="webcal://www.bardarswingclub.no/kalender.ics">foo</a>
    
    

    external by Devonkerai  189  0  2  0

    requests-individ-website-test.py

    requests-individ-website-test.py: requests-individ-website-test.py
    #!/usr/bin/env python
    
    import exceptions
    import requests
    import httplib
    import urllib2
    
    def request_testing():
    	try:
    		timeout = 30
    		# proxy = 'http://192.168.56.1:8888'
    		proxy = ''
    		# url = "http://www.bsp.gov.ph/banking/quasi.pdf"
    		# url = "http://cca.hawaii.gov/dfi/files/2013/05/Mortgage-Servicer-04.01.14.pdf"
    		# url = "http://www.sec.gov.ph/investorinfo/registeredentity/GSEDs.pdf"
    		url = "http://acpr.banque-france.fr/fileadmin/user_upload/acp/Agrements_et_autorisations/Procedures_secteur_assurance/Passeport_europeen_assurance/201312-Succursales-europeennes-entreprises-francaises-exercant-en-LPS-dans-EEE.pdf"
    		headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36'}
    		response = requests.get(url, headers=headers, proxies={'http':proxy}, timeout=timeout)
    		print "Successfully connected to the website!"
    		print "Successful Response Headers: %s" % response.headers
    		print "Successful Response Status Code: %s" % response.status_code
    		print "Successful Request Headers: %s" % response.request.headers
    	except (httplib.BadStatusLine, urllib2.HTTPError, exceptions.NameError, urllib2.URLError) as e:
    		print "Error: %s" % e
    		print "Could not connect to the website :("
    		print "Broken Response Headers: %s" % response.headers
    		print "Broken Response Status Code: %s" % response.status_code
    
    if __name__ == '__main__':
    	request_testing()
    
    

    external by Devonkerai  185  0  2  0

    urllib2-individ-website-test.py

    urllib2-individ-website-test.py: urllib2-individ-website-test.py
    #!/usr/bin/env python
    
    import urllib2
    import httplib
    import exceptions
    
    def urllib2_testing():
    	try:
    		timeout = 30
    		#proxy = 'http://192.168.56.1:8888'
    		# url = "http://www.bsp.gov.ph/banking/quasi.pdf"
    		# url = "http://cca.hawaii.gov/dfi/files/2013/05/Mortgage-Servicer-04.01.14.pdf"
    		# url = "http://www.sec.gov.ph/investorinfo/registeredentity/GSEDs.pdf"
    		# url = "http://www.sec.gov.ph/investorinfo/registeredentity/Registered%20BDD%20PSE%20Participants%20092008.pdf"
    		url = "http://acpr.banque-france.fr/fileadmin/user_upload/acp/Agrements_et_autorisations/Procedures_secteur_assurance/Passeport_europeen_assurance/201312-Succursales-europeennes-entreprises-francaises-exercant-en-LPS-dans-EEE.pdf"
    		# proxy = urllib2.ProxyHandler({'http': proxy})
    		# opener = urllib2.build_opener(proxy)
    		# urllib2.install_opener(opener)
    		headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36', 'Accept' : '*/*'}
    		request = urllib2.Request(url, headers=headers)
    		body = urllib2.urlopen(request, timeout=timeout)
    		html = body.read()
    		print "Successfully connected to the website!"
    		print "Successful Response Headers: %s" % body.info()
    		print "Successful Response Status Code: %s" % body.code
    	except (httplib.BadStatusLine, urllib2.HTTPError, exceptions.NameError, urllib2.URLError) as e:
    		print "Error: %s" % e
    		print "Could not connect to the website :("
    
    
    	with open(filename, "wb") as f:
    		f.write(html)
    
    if __name__ == '__main__':
    	urllib2_testing()
    
    

    external by Hongchan Choi  173  0  2  0

    Chromium Web Audio test snippets for run-webkit-tests

    Chromium Web Audio test snippets for run-webkit-tests: audiobuffersource-playbackrate.js
    <!DOCTYPE html>
    <html>
    <head>
      <title>AudioBufferSourceNode - playbackRate test</title>
      <script src="../resources/js-test.js"></script>
      <script src="resources/compatibility.js"></script>
      <script type="text/javascript" src="resources/audio-testing.js"></script>
    </head>
    <body>
      <script>
      description("Test if AudioBufferSourceNode.playbackRate can playback at different rates properly.");
      window.jsTestIsAsync = true;
    
      // The closest number to 44100 as multiple of render quantum.
      var sampleRate = 44160;
    
      // The test iterates over 60 pitches starting from 36. (MIDI pitch of C2)
      var basePitch = 36;
    
      // Duration of each pitch iteration.
      var unitDuration = 0.025;
    
      // Total test duration.
      var totalDuration = unitDuration * 60;
    
      function pitchToFrequency(pitch) {
        return 440 * Math.pow(2, (Math.floor(pitch) - 69) / 12);
      }
    
      function pitchToPlaybackRate(pitch) {
        return Math.pow(2, pitch / 12);
      }
    
      function createSineWaveBuffer(context, frequency, duration) {
        var length = duration * sampleRate;
        var buffer = context.createBuffer(1, length, sampleRate);
        var data = buffer.getChannelData(0);
        var phase = 0, base = 2 * Math.PI * frequency / sampleRate;
        for (var i = 0; i < length; i++)
          data[i] = Math.sin(base * i);
    
        return buffer;
      }
    
      var context = new OfflineAudioContext(1, totalDuration * sampleRate, sampleRate);
    
      // This is the base buffer for playbackRate modulation. The duration of 5 is
      // arbitrary but long enough to produce the sound without running short.
      var baseBuffer = createSineWaveBuffer(context, pitchToFrequency(basePitch), 5);
    
      // A unit test consists of 2 sources and 1 inverter (gain node with -1 gain).
      // The source 1 runs a newly created buffer for an individual pitch, but the
      // source 2 runs the base buffer with a calculated playback rate. The inverter
      // flip the signal of the source 2 and the destination sums two signals from
      // sources.
      //
      // The resulting audio should be silent ideally. However, the summed output
      // will not be complete zeros in many cases due to the artifact of playback
      // rate modulation.
      function runUnitTest(context, unitStart, unitPitch) {
        var source1 = context.createBufferSource();
        var source2 = context.createBufferSource();
        var inverter = context.createGain();
    
        source1.buffer = createSineWaveBuffer(context, pitchToFrequency(unitPitch), unitDuration);
        source2.buffer = baseBuffer;
        source2.playbackRate.value = pitchToPlaybackRate(unitPitch - basePitch);
        inverter.gain.value = -1.0;
    
        source1.connect(context.destination);
        source2.connect(inverter)
        inverter.connect(context.destination);
    
        source1.start(unitStart);
        source1.stop(unitStart + unitDuration);
        source2.start(unitStart);
        source2.stop(unitStart + unitDuration);
      }
    
      // Schedule tests up to 60 pitches above from the base pitch.
      for (var iteration = 0; iteration < 60; iteration++) {
        (function (i) {
          context.suspend(unitDuration * i).then(function () {
            runUnitTest(context, unitDuration * i, basePitch + i);
            context.resume();
          });
        })(iteration);
      }
    
      context.startRendering().then(function (renderedBuffer) {
        var data = renderedBuffer.getChannelData(0);
        var maxDiff = 0;
        for (var i = 0; i < data.length; i++) {
          var diff = Math.abs(data[i]);
          if (diff > maxDiff)
            maxDiff = diff;
        }
    
        console.log(maxDiff);
    
        Should('The maximum absolute difference in the summed buffer', maxDiff)
          .beCloseTo(0.000012040138244628906, 0.000001);
    
        finishJSTest();
      });
    
      successfullyParsed = true;
      </script>
    </body>
    </html>
    
    
    

    external by Paul McKellar  103  0  2  0

    web-test

    web-test: gistfile1.txt
    <h1>
    test
    </h1>
    
    
    

    external by Juan Manuel Mesa  61  0  1  0

    websocket-test

    websocket-test: ws.js
    let msg = {
      name: 'channel add',
      data: {
        name: 'Hardware Support'
      }
    };
    
    let ws = new WebSocket('ws://localhost:4000');
    
    ws.onopen = () => {
      ws.send(stringify(msg));
    };
    
    
    • Public Snippets
    • Channels Snippets