Cricinfo example | Selenium Forum
M
Posted on 13/09/2015
Hi Ashish,

I'm getting below error in cricinfo example which u gave last week and please let me know if the below code works?

----------------------------------------------------------------------------------------
error



Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Incompatible operand types int and WebElement

at Cricinfo.main(Cricinfo.java:35)





---------------------------------------------------------------------------------------

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Cricinfo {
static int Sum =0;

public static void main(String[] args) {

FirefoxDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://www.espncricinfo.com/world-cricket-league-div6-2015/engine/match/913421.html");

List<WebElement> Noofrows = driver.findElements(By.xpath("//table[@class='batting-table innings']/tbody/tr/td[4]"));
WebElement Total = driver.findElement(By.xpath("//table[@class='batting-table innings']/tbody/tr[25]/td[4]"));


//int temp = Noofrows.size();

for(int i=0;i<Noofrows.size()-1;i++){

String s = Noofrows.get(i).getText();
int temp=Integer.parseInt(s);
Sum =Sum+temp;

}
System.out.println(Sum);


if(Sum==Total){
System.out.println("True");
}
else
{
System.out.println("false");
}
}

}

M
Replied on 13/09/2015

[quote="swethamovva51@gmail.com":29ijxerb]
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Incompatible operand types int and WebElement

at Cricinfo.main(Cricinfo.java:35)
[/quote:29ijxerb]

Incompatible operand types int and Web Element.

you're trying to equalize a web element and a integer.


M
Replied on 14/09/2015

oh ok...how can solve this problem...is the below code correct?