A
A
Alexey Poloz2017-08-03 23:05:31
Python
Alexey Poloz, 2017-08-03 23:05:31

Python Selenium Why can't find div?

Prior to that, it calmly finds elements by id and class
. But at this moment there is an error:
elem=driver.find_element_by_id('730_2_8695061953')

Traceback (most recent call last):
  File "main.py", line 30, in <module>
    elem=driver.find_element_by_id('730_2_8695061953')
  File "/Users/kosyachniy/anaconda/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 289, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "/Users/kosyachniy/anaconda/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 791, in find_element
    'value': value})['value']
  File "/Users/kosyachniy/anaconda/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "/Users/kosyachniy/anaconda/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"730_2_8695061953"}
  (Session info: chrome=59.0.3071.115)
  (Driver info: chromedriver=2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform=Mac OS X 10.12.6 x86_64)

This is what the site looks like (copied from the one launched by the application itself):
<div class="item app730 context2" id="730_2_8695061953" style="border-color: rgb(210, 210, 210);">
<img src="http://community.edgecast.steamstatic.com/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpouLWzKjhzw8zFdC5K092kl5SClMj3PLXFhGpC_Pp8j-3I4IG7i1Hn_UI-Nmj3ItDGe1BoN1mCr1G4xL_vhMS8tcmcn3JhuihwsHvbzQv3309k3tBw8A/96fx96fdpx2x">
<a href="#730_2_8695061953" class="inventory_item_link"></a></div>

I need to click on it, but it can't even find it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mipan, 2017-08-03
@mipan

the element may not have time to load before it is searched.

T
TheBububo, 2017-08-04
@TheBububo

Maybe an element inside an iframe

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question