2016-04-05 22 views
-1

Merhaba Ben böyle bir düğmeyi tıklamanız gereken bir senaryo var ve besleme ekranında beğenme sayacı 1 tarafından artırılır şimdi bu sayaç selenium kullanarak doğrulamak gerekir Aslında yükseliyor, çünkü eski değerin ne olduğunu ve yeni değerin ne olduğunu bilmiyorum.Sayaç, selenyum kullanılarak artırılıyor nasıl doğrulanır

biz

+0

Eğer mümkünse aynı örnek url sağlayabilir –

+0

Onun bir mobil uygulama ama size facebook uygulaması veya benzeri sayımlar artar gibi herhangi bir uygulama gibi örnekler verebilirsiniz – Akash

+1

Neden eski değeri bilmiyor musunuz ?! ?! Bunu neden sayfadan okuyamıyorsunuz? – SiKing

cevap

0

Merhaba bu sorgunuzu çözer Umut

// this web-site shows counter ,its same like clicking on like button of face-book 
// here instead of clicking we are refreshing the page or opening the same url again and again 
driver.get("https://www.counter.gd/"); 

// finding the initial value of the counter is : 
String initialCounter = driver.findElement(By.xpath("//*[@name='counter_id']")).getAttribute("value"); 
// printing the value of the counter, also converting the output type to int. 
int countervalBefore = Integer.parseInt(initialCounter); 
System.out.println("value of the counter before click/refresh is : " + countervalBefore); 

// now refresh the page to increase the counter or click like button of the facebook to increase like counter 
driver.navigate().refresh(); 

// now call the counter again 
String afterCounter = driver.findElement(By.xpath("//*[@name='counter_id']")).getAttribute("value"); 
int countervalAfter = Integer.parseInt(afterCounter); 
System.out.println("value of the counter after click/refresh is : " + countervalAfter); 

// now verifying the previous counter value with current counter value 
if(countervalAfter > countervalBefore){ 
    System.out.println("Counter worked i.e incremented"); 
}else{ 
    System.out.println("Counter not working"); 
} 

altına gibi bunu yapabilir bu kullanarak Selen yapabilir.

+0

Teşekkürler Raj Bu küçük değişiklikten sonra benim için çalıştı – Akash

+0

m size yardımcı olduğunu düşündüğünüz takdirde işe yaradı, lütfen cevabınız olarak işaretleyin lütfen –