Open plonknimbuzz opened 1 month ago
https://github.com/kaliiiiiiiiii/Selenium-Driverless?tab=readme-ov-file#iframes
driver.switch_to.frame
shouldn't be used
in Readme:
Note: This project is moving away from the selenium syntax
so how to access frame
element?
selenium_driverless
options = webdriver.ChromeOptions()
async with webdriver.Chrome(options=options) as driver:
await driver.get("http://localhost/frameset.html", wait_load=True)
time.sleep(1)
iframes = await driver.find_elements(By.TAG_NAME, "frame")
await asyncio.sleep(0.5)
iframe_document = await iframes[1].content_document
inpt = iframe_document.find_elements(By.CSS_SELECTOR,'input')
inpt.send_keys('aaa')
time.sleep(2)
error
Traceback (most recent call last):
File "C:\xampp\htdocs\other\mutasi-mudah\debug\test.py", line 80, in <module>
asyncio.run(main2())
File "C:\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\xampp\htdocs\other\mutasi-mudah\debug\test.py", line 61, in main2
inpt = iframe_document.find_elements(By.CSS_SELECTOR,'input')
AttributeError: 'NoneType' object has no attribute 'find_elements'
with selenium
i can do this, but idk how to do it with selenium_driverless
from selenium import webdriver as webdriver2
from selenium.webdriver.common.by import By as By2
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:/selenium/chrome/chrome.exe"
driver = webdriver2.Chrome(options=options )
driver.get("http://localhost/frameset.html")
time.sleep(1)
driver.switch_to.frame('frame2')
inpt = driver.find_element(By2.CSS_SELECTOR,'input')
inpt.send_keys('aaa')
time.sleep(2)
driver.quit()
thanks for you fast reply
my bad let's leave it open for now
changing https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/348b95dbb0025d1343fc3c6ade3540129269ae37/src/selenium_driverless/types/webelement.py#L203 to in ["iframe", "frame"]
might resolve the issue.
https://chromedevtools.github.io/devtools-protocol/tot/DOM/#type-Node for reference
thanks for your help mate
Hi, I got this error, and when i try to read your code, I think u still not implemented
switch_to.frame
correctly. because u treatframe
like aniframe
while both of them have different element behaviourselenium_driverless: 1.9.3.1
https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/348b95dbb0025d1343fc3c6ade3540129269ae37/src/selenium_driverless/scripts/switch_to.py#L119-L121
frameset.html
input1.html
input2.html
test.py
error