Selenium Javaで動作するように書かれた2つの画像を比較する方法について、以下のコードをグーグルで調べています。ただし、以下のようにRuby Selenium で画像ファイルを比較する必要があります。Ruby Seleniumの getData()、getNumBands()、getWidth()、getHeight()、getSample()と同等のメソッドを教えてください。どうもありがとう。
try {
original = ImageIO.read(new File(
"originalFile"));
copy = ImageIO.read(new File("copyFile"));
ras1 = original.getData();
ras2 = copy.getData();
//Comparing the the two images for number of bands,width & height.
if (ras1.getNumBands() != ras2.getNumBands()
|| ras1.getWidth() != ras2.getWidth()
|| ras1.getHeight() != ras2.getHeight()) {
ret=false;
}else{
// Once the band ,width & height matches, comparing the images.
search: for (int i = 0; i < ras1.getNumBands(); ++i) {
for (int x = 0; x < ras1.getWidth(); ++x) {
for (int y = 0; y < ras1.getHeight(); ++y) {
if (ras1.getSample(x, y, i) != ras2.getSample(x, y, i)) {
// If one of the result is false setting the result as false and breaking the loop.
ret = false;
break search;
}