Home > front end >  How can I find a specific button on an Instagram page? What I thought would work isn't
How can I find a specific button on an Instagram page? What I thought would work isn't

Time:11-14

I am trying to click the save info button you get when you first log in to an Instagram account. I can't because I keep getting ElementNotFound errors.

I tried this code and it gave this error:

chrome.find_element(By.CLASS_NAME, "_acan _acap _acas").click()
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1255, in process_application_commands
    await app_command.invoke(interaction)
  File "C:\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 739, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"._acan _acap _acas"}

CodePudding user response:

I can't reproduce that. But I see the problem in you approach. By.CLASS_NAME is searching by one class name but here you are trying to search by three names. class attribute in html store one or more class names. If there are more than one class name in the class attribute, class names are separated with spaces. So "_acan _acap _acas" is not a class name but a list of class names. And I guess none of them is unique for the page.
So, to be able to find the element using all three class names you can do the following:

chrome.find_element(By.XPATH, '//*[@]').click()
  • Related