E
Emsen
Guest
Hi, my Xpath gives me many lines like this:
<td>1.4</td>
<td>2.6</td
><td>5.8</td>
<td>11.2</td>
Each element have click button next to it. I made an condition when to Click the button. How can i loop through all elements and click only on good one's?
Here is my code.
IList<IWebElement> wioski = driver.FindElements(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/div[4]/div/table/tbody//td[contains(@style,'text-align: center;')and contains(text(),'?')]/following-sibling::td[1]"));
String[] wioskiALL = new string[wioski.Count];
int i = 0;
foreach (IWebElement elm in wioski)
{
string uhm = driver.FindElement(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/div[4]/div/table/tbody//td[contains(@style,'text-align: center;')and contains(text(),'?')]/following-sibling::td[1]")).Text;
string liczba = uhm;
Console.WriteLine(liczba);
double d = Convert.ToDouble(liczba.Replace(".", ","));
if (d < 10)
{
foreach (IWebElement wyslij in wioski)
{
driver.FindElement(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/div[4]/div/table/tbody//td[contains(@style,'text-align: center;')and contains(text(),'?')]/following-sibling::td[2]/a")).Click();
}
}
driver.FindElement(By.XPath("//td//table//td//a[@class='manager_icon'] [@title='Asystent Farmera']")).Click();
}
My loop always picks first element and first Click button, how can i jump to next one?
Continue reading...
<td>1.4</td>
<td>2.6</td
><td>5.8</td>
<td>11.2</td>
Each element have click button next to it. I made an condition when to Click the button. How can i loop through all elements and click only on good one's?
Here is my code.
IList<IWebElement> wioski = driver.FindElements(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/div[4]/div/table/tbody//td[contains(@style,'text-align: center;')and contains(text(),'?')]/following-sibling::td[1]"));
String[] wioskiALL = new string[wioski.Count];
int i = 0;
foreach (IWebElement elm in wioski)
{
string uhm = driver.FindElement(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/div[4]/div/table/tbody//td[contains(@style,'text-align: center;')and contains(text(),'?')]/following-sibling::td[1]")).Text;
string liczba = uhm;
Console.WriteLine(liczba);
double d = Convert.ToDouble(liczba.Replace(".", ","));
if (d < 10)
{
foreach (IWebElement wyslij in wioski)
{
driver.FindElement(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/div[4]/div/table/tbody//td[contains(@style,'text-align: center;')and contains(text(),'?')]/following-sibling::td[2]/a")).Click();
}
}
driver.FindElement(By.XPath("//td//table//td//a[@class='manager_icon'] [@title='Asystent Farmera']")).Click();
}
My loop always picks first element and first Click button, how can i jump to next one?
Continue reading...