Click on checkbox

How can i click on a checkbox like this?
image
The checkbox isn’t clickable if I use this
Click xpath=//[@id=“TermoAceite”]
And don’t work use this
Click xpath=//
[@id=“formPosto”]/div[9]/label

Do I have another alternative?

Thanks

With SeleniumLibrary we would use:
Select Checkbox TermoAceite

Hi Lucas,

If @HelioGuilherme66 's answer doesn’t work (it’s the better way) then another thing you can try is simply sending the click to the parent element:

Click xpath=//[@id=“TermoAceite”]/..

Sometimes you need to fiddle to figure out which element is on top and actually receiving the click.

Dave.

I have had this problem very often. The label is blocking the actual checkbox.
The way to make this work is to force click the checkbox. As I need to do this often I created a commonKeyword for it:

(Un)Check Checkbox

    [Arguments]  ${identifier}

    Click  ${identifier}  left  1  None  None  None  true

I see you use the id as a selector, but still put it in an xPath. That is not needed as you can just use id=TermoAceite.

So in your case using the commonKeyword in a test case will look like:

(Un)Check Checkbox id=TermoAceite

Thanks for the help, but with Browser Library nothing worked, I changed to Selenium and use Javascript to solve this problem
${element} Get WebElement id=TermoAceite
Execute Javascript arguments[0].click(); ARGUMENTS ${element}

1 Like

Hi,
I have a similar problem which I struggle to fix it.
The checkbox looks like this

I tried using either Browser Library (Check Checkbox) and with Selenium Library using

${element} =    get webelement    class=aw-jswidgets-checkboxButton
execute javascript    arguments[0].click();     ARGUMENTS ${element}

and
${SELCT_CHKB} = xpath://input[@class=“aw-jswidgets-checkboxButton”]
wait until element is visible ${SELCT_CHKB} 10s
select checkbox ${SELCT_CHKB}

Can someone help me where I did go wrong? Help would be highly appreciated!

Solved the problem! The problem was one div higher.
With Execute JavaScript var a=document.getElementsByClassName(‘aw-splm-tableRow ui-grid-row aw-row-icon aw-splm-tablePinnedRow’); a[0].click();
the checkbox is now selected!

Hi @PyneCone,
I’m also facing the same issue with checkbox click can you please suggest the correct syntax.
You said higher div higher solved the issue…but for me nothing is working to click the checkbox.
getting an error : ElementClickInterceptedException

Hi @SeemaT ,

it is not very helpful if you don’t show what you already tried to do, and where I could probably see the issue. In this case it would be helpful if you could show that part of the DOM tree you want to access and how you tried to reach it.

@PyneCone, thanks for your quick response.
Able to resolve the click checkbox issue using same command which you were using only change I tried getElementByID instead of getElementsByClassName & it worked for me.

Thanks Again

Hi @damies13
i am trying to select tree view checkboxes with xpath but i am unable to select

@Surekha-tfs,

It’s better to start a new thread with your problem rather than jumping on an old thread, you can always link the old thread if you think it’s relevant.

Given what you’ve showed, there’s not much that’s useful for identifying the checkbox you want, the id looks like a generated value that’s likely to change each time you run the test so I wouldn’t rely on that.

I’m guessing that the label for the checkbox might be in the <span> with the class k-treeview-leaf ? if so then your best be is probably to use an xpath to find the checkbox relative to that label.

Dave.

1 Like

Hi,

In those case where the checkbox, button, drop down menu are some kind of customs ones, customs keywords to manage them are useful.

You can build keywords with arguments, to just pass the class, Id or Name of the checkbox, then click on it.

Change Checkbox
    [Arguments]    ${parameter} 
    Click Element    //span[@class='${parameter}']/preceding-sibling::span

As all the application checkbox might be designed the same way, it is reusable. Axis can be set as arguments too, higher keywords can be also designed to verify status before click and modify accordingly.

Regards
Charlie

1 Like