0
votes

I have multiple settings which I need to enabled or disabled in test automation step. I am using python-robot-selenium. I dont want manual to reset requirements before running the script. When my toggle buttons are enabled or disabled the xpath is same for both so I am not able to handle it. Any other way to achieve it?

Below is the xpath and full xpath for both enabled and disabled status of toggle button

Xpath = //*[@id="tabTest"]/div[2]/div[2]/div[2]/label
Full xpath = /html/body/div[2]/div[2]/div[4]/div[1]/div[2]/div/div[1]/div[2]/div[2]/div[2]/label

Buttons and its inspect element is as below.

enter image description here

enter image description here

2

2 Answers

0
votes

somewhere in the code is the colour green instead of grey, I would try to add that in the xpath/searchtree because that is the thing that is unique to the status.

0
votes

Below code is worked for me for me to get background color of toggle button. It will helpful to take the action based on toggle button enabled(Green in color) and disabled(Grey in color).

#Check the status of toggle button whether its enabled or disabled.
    ${BG}   Get WebElement     xpath=(//span[@class="slider round"])[3]
    ${bg color}    Call Method    ${BG}    value_of_css_property    background-color
    Run Keyword If    '${bg color}' == 'rgba(204, 204, 204, 1)'
    ...   Click Element     xpath=(//span[@class="slider round"])[3]
    ...   ELSE
    ...   Click Element    xpath=//*[@id="app"]/div[2]/div[4]/div[1]/div[1]/div/div/ul/li[2]/a