.Text to .Int Converter

0

I'm automating in C # with selenium webdriver. The elements of the screen I get by Xpath and I save in Variable or WebElement, and I need to transform a text element, which is stored in a variable, and add it with another element, which must also be converted.

Code

valorA = driver.FindElement(By.XPath("html/body/div[1]/div[2]/div[3]/div/section/div[2]/div/aside/div[2]/div/div/div[1]/ul/li[1]/div[1]/div[2]/h6/strong"));

valorB = driver.FindElement(By.XPath("html/body/div[1]/div[2]/div[3]/div/section/div[2]/div/aside/div[2]/div/div/div[1]/ul/li[1]/div[1]/div[2]/h7/strong"));
    
asked by anonymous 22.03.2016 / 17:51

1 answer

0

You can only convert a string to an integer type via the conversion method if the string is a number. For example:

string str = "1";
int num = Convert.ToInt16(str);
    
22.03.2016 / 21:03