Как отключить тумблер, когда он включен, используя selenium webdriver с Python - PullRequest
0 голосов
/ 12 июля 2020

У меня здесь есть этот маленький переключатель, мне нужно его выключить, если он включен

toggle

This is how the html look like when it's on: The inner div is for the white circle inside the green, but i can click wherever under the green square.

enter image description here

I usually use CroPath for finding the XPath so I get this:

enter image description here

Usually, I always use

driver.find_element(By.XPATH,path).click()

For clicking buttons and it always work, but for this one I have use the XPath and CSS selector to find the element and it didn't work. Any idea how I can click this toggle?

For reference, this is how the button looks like when it's off and the html behind it:

enter image description here введите описание изображения здесь

1 Ответ

0 голосов
/ 12 июля 2020

возможно, следует использовать щелчок для внутреннего объекта div, я имею в виду, например:

driver.find_element(By.XPATH,path).find_element_by_tag_name('div').click()

Это может сработать.

...