Mehmet Fatih

Mehmet Fatih

  • 858
  • 931
  • 39.5k

Loop based on selected checkbox in selenium

Jan 12 2024 7:31 AM

 I want to create a conditional loop in Selenum. However, I am getting an error on the condition line regarding checkbox. I tried all of the methods below. It gives errors in all of them. What should the condition be like?

if (drv.FindElement(By.Id("chk1")).GetAttribute("checked") != null) 

if   (isChecked = drv.FindElement(By.Id("chkS1")).GetAttribute("checked").equals("true"))

 if (drv.FindElement(By.Id("chkS2")).GetAttribute("checked").Equals("true")) 

 if (drv.FindElement(By.Id("chkS2")).GetAttribute("checked")..isSelected) 

 

if (drv.FindElement(By.Id("chkS1")).GetAttribute("checked") .Selected()) 

if (drv.FindElement(By.Id("chk1")).GetAttribute("checked") != null)        
 {
     var yaz1 = dataGridView1.Rows[i].Cells[3].Value.ToString();
     drv.FindElement(By.Id("not1_" + (i))).SendKeys(yaz1);
 }
 else if (drv.FindElement(By.Id("chk2")).GetAttribute("checked") != null)    

 {
     var yaz2 = dataGridView1.Rows[i].Cells[4].Value.ToString();
     drv.FindElement(By.Id("not2__" + (i))).SendKeys(yaz2);
 }

 


Answers (2)