Jump to content

unchecking Checkbox in Chrome Automation


Recommended Posts

 

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='rdoPatientRelationshipSelf']")
 _WD_ElementAction($sSession,$sButton,'value','1')
Exit

Hi @Danp2

 

I try to check the Check in Chrome Automation.

Could you please help me to fix this. I tried Click and Value Change 

 

image.thumb.png.9e8b5ce6e01d1ed5f453c8245423116d.png

 

Thanks in Advance

Regards

Ragavendran @ ALan

Link to comment
Share on other sites

Normally, you would just use _WD_ElementAction with the 'click' action to toggle the checkbox. Here's an example --

#include "wd_core.au3"

Local $sDesiredCapabilities, $sSession, $sElement, $sElement2, $sInnerText
Local $sXpath = "//input[@id='sports']"

SetupChrome()
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)
If @error = $_WD_ERROR_Success Then
    _WD_Navigate($sSession, "https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/input/checkbox$samples/Examples?revision=1621784")

    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sXpath)

    If @error = $_WD_ERROR_Success Then
        Sleep(3000)
        $sInnerText = _WD_ElementAction($sSession, $sElement, 'click')
        Sleep(3000)
        $sInnerText = _WD_ElementAction($sSession, $sElement, 'click')
        Sleep(3000)
    EndIf
EndIf

_WD_DeleteSession($sSession)
_WD_Shutdown()

Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true}}}}'
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...