asperduti / creator-studio-cli

Tool for automated interactions on Creator Studio, like upload to Instagram or Facebook.
MIT License
19 stars 2 forks source link

selenium.common.exceptions.NoSuchElementException: #9

Closed Suvanch closed 2 years ago

Suvanch commented 3 years ago

How should I go about fixing this problem?

This is the full error message

User is logged trying instagram tab Timeout Exception in explicit wait Traceback (most recent call last): File "from_csv.py", line 15, in cs_cli.create_post(account=post[0], File "/home/a/creator-studio-cli/creator_studio/creator_studio.py", line 32, in create_post instagram.create_post(self.browser, account, message, file, schedule_options=schedule_options) File "/home/a/creator-studio-cli/creator_studio/instagram.py", line 33, in create_post create_post_button = browser.find_element_by_xpath(xpath["instagram"][create_post.name]["create_post_button"]) File "/home/a/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/home/a/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/home/a/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/a/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[text()='Create Post']

asperduti commented 3 years ago

Hi @Suvanch Which method are you using to logging? A session(with an account already logged in) or user and password.

To start using this tool, there are two requirements:

Do you meet the requirements? Here you have a title explanation https://github.com/asperduti/creator-studio-cli/issues/5#issuecomment-687132951

And another question, in the browser, what is the last page that you see when the exception is triggered?

Suvanch commented 3 years ago

This is the last thing I see https://user-images.githubusercontent.com/54117989/128374225-3f8a8d92-b5c6-4d02-bd28-aec752760428.png Screenshot from 2021-08-05 09-47-23

Yes I am using U.S English and my accounts are connected. Shouldn't it move to the Instagram tab on the top.

asperduti commented 3 years ago

This is the last thing I see https://user-images.githubusercontent.com/54117989/128374225-3f8a8d92-b5c6-4d02-bd28-aec752760428.png Screenshot from 2021-08-05 09-47-23

Ok good, you are logged, all is ok there.

Shouldn't it move to the Instagram tab on the top.

Yes.

Can you share the code that you are using?

Suvanch commented 3 years ago

It's the same code as in the repo. How were you able to identify a button on facebook? When I look for a buttons class name there is just a string of chars.

asperduti commented 3 years ago

It's the same code as in the repo.

It's not exactly the same. In the log you have this:

trying instagram tab

This is not part of the code on the repo.

How were you able to identify a button on facebook? When I look for a buttons class name there is just a string of chars.

To look for buttons, in some cases I use class name or id, and in other the text in the button(This is the reason to use US English). Unfortunately, the class name are not always the same. Some of these changes between sessions. And other changes when there are changes in the UI, maybe this is the case. Let me see. If this is the case. I do not see the message Unable to find Instagram Button in your log.

Update: For the Instagram button I use the id of the button, that is media_manager_chrome_bar_instagram_icon . I checked the UI, and is the same, there was no change.

image

Suvanch commented 3 years ago

Ok thanks for your help

I assumed it had to go through the Instagram page to make the post but I didn't implement it yet. The code I ran from was directly from the repo.

Do you happen to know why the error may be happening?

asperduti commented 3 years ago

Ok thanks for your help

I assumed it had to go through the Instagram page to make the post but I didn't implement it yet. The code I ran from was directly from the repo.

Do you happen to know why the error may be happening?

What code? the example?

Check in your browser if the id of the button is media_manager_chrome_bar_instagram_icon.

When the exception was triggered, was the page fully loaded?

Did you run the code only once?