what I want the code to do is basically simple, I want it to go to all articles and selects all article ratings and then parse the returned rating into an int, and then checks (on a checkbox in each article) the articles that has a rating of 5 or higher, and I want it to check maximally ten articles. the code is below:
string notes = driver.FindElement(By.XPath("//article[]/div/div[1]/div/div/span"))
.Text.Replace(" notes", "");//here I just had to remove the word notes from the rating in order to use this variable.
int Notes;
Notes = int.Parse(notes);
int article = 0;
if (Notes >= 5)
{
do //>--the number of articles selected
{
driver.FindElement(By.XPath("//article[]/div/div[2]/div[1]/div[2]")).Click();
article = article + 1;
} while (article < 10);
}
what actually happens is that it checks the first articles ten times(or better said it checks and unchecks the checkbox five times), and then it proceeds with the rest of test, so can anyone tell me how to fix it.
Aucun commentaire:
Enregistrer un commentaire