Last active
September 25, 2017 20:39
-
-
Save shashikantjagtap/eac9a722551628ce9745 to your computer and use it in GitHub Desktop.
Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'oily_png' | |
file1, file2, file3 = ARGV | |
images = [ | |
ChunkyPNG::Image.from_file("#{file1}"), | |
ChunkyPNG::Image.from_file("#{file2}") | |
] | |
images.first.height.times do |y| | |
images.first.row(y).each_with_index do |pixel, x| | |
images.last[x,y] = ChunkyPNG::Color.rgb( | |
ChunkyPNG::Color.r(pixel) + ChunkyPNG::Color.r(images.last[x,y]) - 2 * [ChunkyPNG::Color.r(pixel), ChunkyPNG::Color.r(images.last[x,y])].min, | |
ChunkyPNG::Color.g(pixel) + ChunkyPNG::Color.g(images.last[x,y]) - 2 * [ChunkyPNG::Color.g(pixel), ChunkyPNG::Color.g(images.last[x,y])].min, | |
ChunkyPNG::Color.b(pixel) + ChunkyPNG::Color.b(images.last[x,y]) - 2 * [ChunkyPNG::Color.b(pixel), ChunkyPNG::Color.b(images.last[x,y])].min | |
) | |
end | |
end | |
images.last.save("#{file3}.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
URL_ONE=$1 | |
URL_TWO=$2 | |
SCREEN_SIZE=$3 | |
echo " =======TAKING SCREENSHOT OF $URL_ONE=======" | |
phantomjs lib/responsive-screens.js $URL_ONE png | |
echo " ======TAKING SCREENSHOT OF $URL_TWO=========" | |
phantomjs lib/responsive-screens.js $URL_TWO png | |
stripedurl1=`echo "${URL_ONE}" | sed "s/^http:\/\///g"` | |
echo "*******SCREENSHOTS OF THE URL_TWO STORED AT ************* /$stripedurl1" | |
stripedurl2=`echo "${URL_TWO}" | sed "s/^http:\/\///g"` | |
echo "S*******SCREENSHOTS OF THE URL_TWO STORED AT ************* /$stripedurl2" | |
echo " ==COMPARING SCREENSHOT OF $URL_ONE AND $URL_TWO====PLEASE WAIT ===" | |
sleep 2 | |
bundle exec /usr/bin/ruby19 compare.rb ${stripedurl1}/${SCREEN_SIZE}.png ${stripedurl2}/${SCREEN_SIZE}.png diff | |
if [ -f diff.png ] | |
then | |
echo "An image diff file 'diff.png' has been created in the root project directory" | |
else | |
echo "Unable to create diff file" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL=$1 | |
rm -rf html | |
mkdir html | |
curl ${URL} >> html/Url1.html | |
npm install | |
./node_modules/.bin/grunt accessibility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
'use strict'; | |
grunt.initConfig({ | |
jshint: { | |
all: [ | |
'Gruntfile.js', | |
'lib/tasks/*.js' | |
] | |
}, | |
accessibility: { | |
options : { | |
accessibilityLevel: 'WCAG2A', | |
domElement: false, | |
force: true, | |
ignore : [ | |
'WCAG2A.Principle1.Guideline1_1.1_1_1.G73,G74', | |
'WCAG2A.Principle2.Guideline2_4.2_4_4.H77,H78,H79,H80,H81' | |
] | |
}, | |
test : { | |
files: [{ | |
expand : true, | |
cwd : 'html', | |
src : ['*.html'], | |
dest : 'reports/', | |
ext : '-report.txt' | |
}] | |
} | |
}, | |
phantomas : { | |
grunt : { | |
options : { | |
assertions : { | |
assetsWithQueryString : 3, | |
bodyHTMLSize : 10500, | |
jsErrors : 10, | |
gzipRequests : { | |
type : '<', | |
value : 10 | |
} | |
}, | |
indexPath : './phantomas/', | |
options : { | |
'timeout' : 60 | |
}, | |
url : 'URL TO TEST' | |
} | |
} | |
} | |
}); | |
grunt.loadTasks('lib/tasks'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-accessibility'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.registerTask('default', ['jshint', 'accessibility']); | |
grunt.loadNpmTasks('grunt-phantomas'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_window_size(width, height) | |
Capybara.current_driver == :poltergeist | |
Capybara.current_session.driver.resize(width, height) | |
end | |
begin | |
window_sizes = { | |
:'320' => { :width => 320, :height => 480 }, | |
:'600' => { :width => 600, :height => 769 }, | |
:'770' => { :width => 770, :height => 1025 }, | |
:'1026' => { :width => 1026, :height => 1200 }, | |
} | |
window_sizes.default = { :width => 994, :height=> 689 } | |
size = window_sizes[(ENV['DEVICE'] || 'default').to_sym] | |
set_window_size(size[:width], size[:height]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "programmes-test", | |
"version": "0.0.0", | |
"description": "NodeJS dependencies", | |
"dependencies": { | |
"grunt": "*", | |
"grunt-cli": "*", | |
"webdriverjs" : "*", | |
"appium": "*", | |
"grunt-contrib-watch": "*", | |
"grunt-contrib-jshint": "*", | |
"phantomjs": "1.9.11", | |
"grunt-accessibility": "*", | |
"grunt-phantomas": "*", | |
"phantomas": "*" | |
}, | |
"author": "BBC Programmes Test Team" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/poltergeist' | |
Capybara.register_driver :poltergeist do |app| | |
options = { | |
:js_errors => true, | |
:timeout => 120, | |
:debug => false, | |
:phantomjs_options => ['--load-images=no', '--disk-cache=false'], | |
:inspector => true, | |
} | |
Capybara::Poltergeist::Driver.new(app, options) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
REPORT_FILE="" | |
REPORT_LOCATION="" | |
THRESHOLD="A" | |
show_usage() { | |
echo "Usage: yslow [report] [threshold] [url ...]" | |
echo | |
echo " [report] location to record results, with trailing slash" | |
echo " [threshold] the testing score threshold ([0-100]|[A-F])" | |
echo " [url ...] URLs to test" | |
} | |
read_args() { | |
while getopts "h" OPTION; do | |
case ${OPTION} in | |
h) | |
show_usage | |
exit 0 | |
;; | |
?) | |
show_usage | |
exit 1 | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
REPORT_LOCATION=$1 | |
THRESHOLD=$2 | |
if [ $# -lt 3 ]; then | |
show_usage | |
exit 1 | |
fi | |
} | |
read_args "$@" | |
for (( i=3; i<=$#; i++ )); do | |
eval url=\$$i | |
REPORT_FILE="${REPORT_LOCATION}report_$(($i-2)).xml" | |
phantomjs lib/yslow.js --info grade --threshold ${THRESHOLD} --format junit ${url} > ${REPORT_FILE} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment