Webdriver Firefoxdriver, run checkbox click

Asked

Viewed 406 times

0

I am creating a robot to log into a page, mark a checkbox and download an export file. However I am not able to run checked in a checkbox. I am using Selenium Webdriver with Firefoxdriver with the method via Xpath:

    IWebDriver driver = new FirefoxDriver();
                driver.Url = "";

                driver.Manage().Window.Maximize();
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

    driver.FindElement(By.XPath
    ("//div[@class='d-flex flex-row']//input[@type='checkbox']")).Click();

Images from the website: inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • gives some error or just click?

  • @Lucasmiranda just don’t click!

  • Have you tried clicking span or in the svg? This has happened to me, when I can’t click directly on input of a checkbox I try to click the element on top of it

  • @Tmilitino I’m not very familiar with fitting xPath properly! Using the above example you could show me how xPath would look to click on span or svg?

1 answer

1


As I said in the comment, your code would look something like this, it would only change the element you were looking for. As the input is "covered up" by other elements it becomes more difficult to perform some kind of action with it.

 IWebDriver driver = new FirefoxDriver();
                driver.Url = "";

                driver.Manage().Window.Maximize();
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

    driver.FindElement(By.XPath("//span[@class='jss78']")).Click(); 

Obs: looking better the HTML you can’t click on svg because he is marked as hidden hidden=True.

You can learn more about XPATH in this link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.