kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver

Home Page:https://kaliiiiiiiiii.github.io/Selenium-Driverless/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] `By.CSS_SELECTOR` wrong number of elements

milahu opened this issue · comments

if class_name == 'NodeList' or _type == 'htmlcollection':
elems = JSNodeList(obj_id=obj_id, target=target, class_name=class_name, isolated_exec_id=isolated_exec_id,
frame_id=frame_id)
for idx in range(int(description[-2])):
elems.append(await elems.__exec__("return obj[arguments[0]]", idx, serialization="deep",
execution_context_id=context_id))
return elems

in the class_name == 'NodeList' case
description == "NodeList(15)"
so description[-2] == 5
so driver.find_elements only returns 5 of 15 elements

in the _type == 'htmlcollection' case
description == "HTMLCollection(15)"
...

fix

-  int(description[-2])
+  int(description[len(class_name)+1:-1])

similar #149

Uhh you're right! Thanks a lot

I've as well considered using javascript for performance instead. However, returning a list then might not return some details at depth=1=>element.

hmm? a quickfix would be Array.from(x.querySelector(y))