Page Link : https://contacts.google.com/u/1/?pageId=none
Desired: I want to select all contacts by clicking the highlighted SVG caret icon in attached image.
Problem facing : Getting error element not visible on svgicon.click()
. Though element is clearly available in visible DOM as per image attached.
Observation : I have noticed that if we manually click on caret icon then DropDown html code is being inserted via JavaScript & on any other body click it is removing the DropDown html code.
I know following code statement used to achieve the desired is correct & working but not populating DropDown . Any help is much appreciated.
//find & click on SVG icon
svgicon = driver.find_element_by_css_selector('div.PFdmz .uzHa0d .RANAid[role="button"]')
svgicon.click()
//click on all link post dropdown appears
wait5.until(EC.presence_of_element_located((By.XPATH, '//div[@class = "jO7h3c" and text() = "All"]'))).click()
DOM Image
EDIT 1 - Sample Javascript effort to select all checkboxes
t=0
for _ in range(len(driver.find_elements_by_css_selector('.XXcuqd div[role="checkbox"]'))):
cimgs = driver.find_elements_by_css_selector('.XXcuqd div[role="checkbox"]')
ActionChains(driver).move_to_element(cimgs[t]).perform()
driver.execute_script("arguments[0].click();", cimgs[t])
t = t+1
if somehow we can use this method to reduce time taken to mark all checkboxes checked (at one go in place of using Actionchains) then this will solve problem too. At any point of time i will have 10000+ contacts for this activity.
For some reason you need to double click the icon:
Well, after investing 15+ days in research, learning & SO community help, nothing worked as expected hence i had to go to 2nd option (undesirable) to meet the purpose.
Working answer
This method is way faster than using Actionchains i had shown in EDIT 1 - Sample Javascript effort to select all checkboxes.
Anyway, thanks everyone for putting your mind to solve a puzzle though it's still a puzzle to me. But considering amount of efforts put up by everyone, bounty owner is @Dan-Dev. Thanks @Dan-Dev & keep helping people like us.
I don't know why but Dan-dev's code performs the result you need, I have tried it and it works fine for me. In this case I'll just put another alternative to what I have done before when I encountered a similiar problem like yours might somehow work for you. Here's my code:
In your first code example,
the selector matches four elements, and the checkbox you are looking for is the fourth. If you haven't already, please try
instead of that line.
I'm immediately sure about the JS executor but could take a look if the above code doesn't work.