Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to locate 'textarea' element when running the demo code #19

Closed
arthurlacoste opened this issue Jul 9, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@arthurlacoste
Copy link

arthurlacoste commented Jul 9, 2023

Hi, first of all thank you for this clever project !

Operating System:

macOS 13.4.1 (22F82)

Description:
I encountered an error while running the demo code on my local machine. The code is designed to interact with a chatbot using the credentials provided. However, when executing the code, I received a NoSuchElementException indicating that the 'textarea' element could not be located.

Steps to Reproduce:

  1. Clone the repository and navigate to the appropriate directory.
  2. Ensure all necessary dependencies are installed.
  3. Run the demo code with valid credentials.
  4. Observe the error traceback.

Expected Behavior:
The code should successfully locate the 'textarea' element and interact with the chatbot, providing an appropriate response.

Actual Behavior:
The code fails to locate the 'textarea' element and raises a NoSuchElementException error.

Error Message:

Traceback (most recent call last):
  File "/Users/art/Dropbox/dev/chatgpt/main.py", line 5, in <module>
    answer = chatgpt.interact("Hello, how are you today")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/chatgpt_automation/chatgpt_client.py", line 242, in interact
    text_area = self.browser.find_element(By.TAG_NAME, 'textarea')
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 740, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute
    self.error_handler.check_response(response)
  File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"tag name","selector":"textarea"}
  (Session info: chrome=114.0.5735.198); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
0   undetected_chromedriver             0x00000001047886b8 undetected_chromedriver + 4937400
1   undetected_chromedriver             0x000000010477fb73 undetected_chromedriver + 4901747
2   undetected_chromedriver             0x000000010433d616 undetected_chromedriver + 435734
3   undetected_chromedriver             0x0000000104380e0f undetected_chromedriver + 712207
4   undetected_chromedriver             0x00000001043810a1 undetected_chromedriver + 712865
5   undetected_chromedriver             0x00000001043c29a4 undetected_chromedriver + 981412
6   undetected_chromedriver             0x00000001043a503d undetected_chromedriver + 860221
7   undetected_chromedriver             0x00000001043bfe76 undetected_chromedriver + 970358
8   undetected_chromedriver             0x00000001043a4de3 undetected_chromedriver + 859619
9   undetected_chromedriver             0x0000000104372d7f undetected_chromedriver + 654719
10  undetected_chromedriver             0x00000001043740de undetected_chromedriver + 659678
11  undetected_chromedriver             0x00000001047442ad undetected_chromedriver + 4657837
12  undetected_chromedriver             0x0000000104749130 undetected_chromedriver + 4677936
13  undetected_chromedriver             0x000000010474fdef undetected_chromedriver + 4705775
14  undetected_chromedriver             0x000000010474a05a undetected_chromedriver + 4681818
15  undetected_chromedriver             0x000000010471c92c undetected_chromedriver + 4495660
16  undetected_chromedriver             0x0000000104767838 undetected_chromedriver + 4802616
17  undetected_chromedriver             0x00000001047679b7 undetected_chromedriver + 4802999
18  undetected_chromedriver             0x000000010477899f undetected_chromedriver + 4872607
19  libsystem_pthread.dylib             0x00007ff80c1c71d3 _pthread_start + 125
20  libsystem_pthread.dylib             0x00007ff80c1c2bd3 thread_start + 15
@ugorsahin
Copy link
Owner

I couldn't reproduce the error unfortunately, everything works as expected on my end. However, with commit 4fadd67 I add an extra step in case of failure on tag search. Please pull and install the latest version and let me know if the problem persists.

@arthurlacoste
Copy link
Author

Thank you for your fast reply !

This is not working; I am still encountering this error.

art@afk chatgpt % python3 main.py
2023/07/10 19:15:18 INFO Verbose mode active
2023/07/10 19:15:18 INFO Loading undetected Chrome
2023/07/10 19:15:19 INFO patching driver executable /Users/art/Library/Application Support/undetected_chromedriver/undetected_chromedriver
2023/07/10 19:15:20 INFO Loaded Undetected chrome
2023/07/10 19:15:20 INFO Opening chatgpt
2023/07/10 19:15:21 INFO Element //button[//div[text()="Log in"]] has found
2023/07/10 19:15:21 INFO Clicked login button
2023/07/10 19:15:23 INFO Element username has found
2023/07/10 19:15:23 INFO Filled email box
2023/07/10 19:15:23 INFO Element //button[text()="Continue"] has found
2023/07/10 19:15:25 INFO Clicked continue button
2023/07/10 19:15:25 INFO Element password has found
2023/07/10 19:15:25 INFO Filled password box
2023/07/10 19:15:26 INFO Logged in
2023/07/10 19:15:32 INFO Info screen skipped
2023/07/10 19:15:32 INFO ChatGPT is ready to interact
2023/07/10 19:15:32 INFO Unable to locate text area tag. Switching to ID search
Traceback (most recent call last):
  File "/Users/art/Dropbox/dev/chatgpt/main.py", line 7, in <module>
    answer = chatgpt.interact("Hello, how are you today")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/chatgpt_automation/chatgpt_client.py", line 262, in interact
    raise RuntimeError('Unable to find the text prompt area. Please raise an issue with verbose=True')
RuntimeError: Unable to find the text prompt area. Please raise an issue with verbose=True

@ugorsahin
Copy link
Owner

That seems strange because I have the tags and everything the same in my end.

I can help you further but I need more information. Please follow the steps below:

  1. If you running it from a script, try to run it from jupyter notebook or an interactive environment to keep chrome open.
  2. Pass headless=False to the constructor and reproduce the error.
  3. When you hit the error once more please right click the Text prompt area and click inspect. (see image below)
    sam_1
  4. Developer tools will show up on the screen. Please select the highligthed area and add here. (see image below)
    sam_2

Hopefully, I can address the issue after that.

@arthurlacoste
Copy link
Author

Ok, after setting headless=False, I realized that there was a mistake in my credentials, now it's working great!

@ugorsahin
Copy link
Owner

Cool, it is great to hear that! Thank you for the letting me know about the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants