dimanche 19 juin 2022

Is checkbox checked true or false // C# Selenium

I am struggling with a simple Checkbox on Side:

https://eas.forexsb.com/

Navigate on top into the blue line to the second DropDown and switch from Generator to Reactor. Than navigate to "3. Generator settings"

The Checkbox "Generate strategies with Preset Indicators" make trouble for me.

My goal is to identify if this is checked or not. If not it should be checked.

In HTML i always find the same.

Checked=
<input class="busy-disabled" id="use-preset-indicators" type="checkbox">
Unchecked=
<input class="busy-disabled" id="use-preset-indicators" type="checkbox">

Than i searched a lot around and found some nice looking examples. Like this one: But there is no Attribute(?)

                //if (!element.GetAttribute("disabled").isEmpty())// && element.GetAttribute("disabled").contains("disabled"))
                //{
                //    //System.out.println("Disabled must be present");
                //    checkBoxStatus = "disabled";
                //    Assert.assertTrue(true);
                //}
                //else
                //{
                //    //System.out.println("Should not it be enabled  ?  or do we need if-else to handle that part as well.");
                //    Assert.assertTrue(false);
                //}

Or another Example starts with this line. But i got the response that IWebelement cannot be convertet to Webelement:

WebElement element = webdriver.FindElement(By.XPath("//span[@title='fieldItem']//preceding-sibling::input"));

Than there is a pretty cool looking code, but i have no isEnabled()...

boolean enabled = driver.findElement(By.xpath("//xpath of the checkbox")).isEnabled();

Did you have an idea how to solf my problem? I only want to check the status and enable/check the checkbox if it is not checked.




Aucun commentaire:

Enregistrer un commentaire