Closed pythondeveloperz closed 9 months ago
@pythondeveloperz Please provide the full stack
elements21 = await driver.find_element(By.CSS_SELECTOR, '#rso > div:nth-child(1) > div > div > div.kb0PBd.cvP2Ce.jGGQ5e > div > div > span > a > h3 > span',timeout=300)
Traceback (most recent call last):
File "C:\Users\pcs\PycharmProjects\pythonProject1\main.py", line 21, in <module>
asyncio.run(main())
File "C:\Users\pcs\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\pcs\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "C:\Users\pcs\PycharmProjects\pythonProject1\main.py", line 15, in main
elements21 = await driver.find_element(By.CSS_SELECTOR, '#rso > div:nth-child(1) > div > div > div.kb0PBd.cvP2Ce.jGGQ5e > div > div > span > a > h3 > span',timeout=300)
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\selenium_driverless\webdriver.py", line 877, in find_element
return await target.find_element(by=by, value=value, parent=parent, timeout=timeout)
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\selenium_driverless\types\target.py", line 575, in find_element
elem = await parent.find_element(by=by, value=value, timeout=None)
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\selenium_driverless\types\webelement.py", line 252, in find_element
elems = await self.find_elements(by=by, value=value)
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\selenium_driverless\types\webelement.py", line 287, in find_elements
res = await self.__target__.execute_cdp_cmd("DOM.querySelectorAll", {"nodeId": node_id,
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\selenium_driverless\types\target.py", line 781, in execute_cdp_cmd
result = await self.socket.exec(method=cmd, params=cmd_args, timeout=timeout)
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\cdp_socket\socket.py", line 78, in exec
raise e
File "C:\Users\pcs\PycharmProjects\pythonProject1\venv\lib\site-packages\cdp_socket\socket.py", line 72, in exec
res = await asyncio.wait_for(self._responses[_id], timeout=timeout)
File "C:\Users\pcs\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 447, in wait_for
return fut.result()
cdp_socket.exceptions.CDPError: {'code': -32000, 'message': 'Could not find node with given id'}
Process finished with exit code 1
@pythondeveloperz Ahh yep that's at https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/4be24f290fe2d9253bb573b4f2384e551e411835/src/selenium_driverless/types/webelement.py#L286-L289
should be catched and then raise a StaleElementReference
to fix.
This issue is related to https://github.com/kaliiiiiiiiii/Selenium-Driverless/discussions/119#discussioncomment-7689642
@pythondeveloperz Ahh yep that's at
should be catched and then raise a
StaleElementReference
to fix. This issue is related to #119 (reply in thread)
sorry bro i dont understand you well is there something i must edit in my code or there is a problem on package you will fix in the next realse?
sorry bro i dont understand you well is there something i must edit in my code or there is a problem on package you will fix in the next realse? @pythondeveloperz Will be fixed in the next release
sorry bro i dont understand you well is there something i must edit in my code or there is a problem on package you will fix in the next realse? @pythondeveloperz Will be fixed in the next release
okay thanks please how can i make scroll down by selenium-driverless package ?
I found a tricky way to fix most of 'Could not find node with given id'
errors: before doing some actions (like getting page_source or find some element), set tab._document_elem_ = None
, so that the "local" tab._document_elem_
will be updated before your actions really taken.
BTY, scroll down could be done by tab.execute_script("window.scrollTo(0, document.body.scrollHeight+1000);")
(I used +1000
to make sure tab really scrolled to end). Or, you can do it by finding the last <div>
or <p>
or other element that has valid rect
attribute, and call div_last.scroll_to()
I found a tricky way to fix most of
'Could not find node with given id'
errors: before doing some actions (like getting page_source or find some element), settab._document_elem_ = None
, so that the "local"tab._document_elem_
will be updated before your actions really taken.
Yep, but eventho that doesn work, it isn't optimized. I'll provide another solution for that.
BTY, scroll down could be done by
tab.execute_script("window.scrollTo(0, document.body.scrollHeight+1000);")
(I used+1000
to make sure tab really scrolled to end). Or, you can do it by finding the last<div>
or<p>
or other element that has validrect
attribute, and calldiv_last.scroll_to()
Jep, JavaScript is detectable this way tho. I'll be refactoring the scrolling anyways.
81a0f7d#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741L285-R287 should fix this
is there a new release after 1.7 ? or try it with this version?
81a0f7d#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741L285-R287 should fix this
is there a new release after 1.7 ? or try it with this version?
Nope that's only in the dev-branch yet. see readme for installation
81a0f7d#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741L285-R287 should fix this
is there a new release after 1.7 ? or try it with this version?
Nope that's only in the dev-branch yet. see readme for installation
i installed the dev-branch through pip install https://github.com/kaliiiiiiiiii/Selenium-Driverless/archive/refs/heads/dev.zip
please how can i test the code in dev branch ?
i installed the dev-branch through pip install https://github.com/kaliiiiiiiiii/Selenium-Driverless/archive/refs/heads/dev.zip
please how can i test the code in dev branch ?
Haha wdym? Now it's installed - good to go lol
ahh heck almost forgot about releasing from the dev branch lol - I'll dl that asap
resloved by 81a0f7d#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741L285-R287
i update package now to 1.7.1 and try the code it give me another error 👍
Traceback (most recent call last):
File "C:\Users\HP\PycharmProjects\pythonProject\main.py", line 19, in
Process finished with exit code 1
resloved by 81a0f7d#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741L285-R287
i update package now to 1.7.1 and try the code it give me another error 👍
Traceback (most recent call last): File "C:\Users\HP\PycharmProjects\pythonProject\main.py", line 19, in asyncio.run(main()) File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "C:\Users\HP\PycharmProjects\pythonProject\main.py", line 15, in main elements21 = await driver.find_element(By.CSS_SELECTOR, '#rso > div:nth-child(1) > div > div > div.kb0PBd.cvP2Ce.jGGQ5e > div > div > span > a > h3 > span',timeout=5) File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\selenium_driverless\webdriver.py", line 889, in find_element return await target.find_element(by=by, value=value, parent=parent, timeout=timeout) File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\selenium_driverless\types\target.py", line 580, in find_element raise NoSuchElementException() selenium_driverless.types.webelement.NoSuchElementException
Process finished with exit code 1
@pythondeveloperz Are you sure the selectors haven't changed since then?
resloved by 81a0f7d#diff-eb355e1147cb9c933fac6232a336122a60ef8bafb5a2661496aeb58ba142f741L285-R287
i update package now to 1.7.1 and try the code it give me another error 👍 Traceback (most recent call last): File "C:\Users\HP\PycharmProjects\pythonProject\main.py", line 19, in asyncio.run(main()) File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "C:\Users\HP\PycharmProjects\pythonProject\main.py", line 15, in main elements21 = await driver.find_element(By.CSS_SELECTOR, '#rso > div:nth-child(1) > div > div > div.kb0PBd.cvP2Ce.jGGQ5e > div > div > span > a > h3 > span',timeout=5) File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\selenium_driverless\webdriver.py", line 889, in find_element return await target.find_element(by=by, value=value, parent=parent, timeout=timeout) File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\selenium_driverless\types\target.py", line 580, in find_element raise NoSuchElementException() selenium_driverless.types.webelement.NoSuchElementException Process finished with exit code 1
@pythondeveloperz Are you sure the selectors haven't changed since then?
i tried it now it sometime work and sometime not i think is there a problem on loading element of webpage how can i detect through the package that all element of the webpage are loaded ?
hello please how can i solve this error the error appeared from line before last related to (element21)
platform : windows 11 python version 3.10 selenium-driverless : 1.7