Closed QuickSliding closed 2 weeks ago
@QuickSliding Please provide some minimum reproducible code
@kaliiiiiiiiii
from selenium_driverless import webdriver
from selenium_driverless.types.by import By
import asyncio
async def main():
options = webdriver.ChromeOptions()
async with webdriver.Chrome(options=options) as driver:
await driver.get("https://kaliiiiiiiiii.github.io/Selenium-Driverless/api/By/", wait_load = True)
dl_list = await driver.find_elements(By.CSS_SELECTOR, 'dl.py.attribute')
for dl in dl_list:
print (await dl.text)
print ('____________________')
for dl in dl_list:
element = await dl.find_element(By.XPATH, "//dl[contains(@class, 'attribute')]")
print (await element.text)
asyncio.run(main())
https://stackoverflow.com/questions/59113577/selenium-in-python-finding-an-element-via-relative-xpath
Apparently, XPATH expects .//
when searching relative
smth like
element = await dl.find_element(By.XPATH, './/span[@class="sig-name descname"]')
works just fine
UPDATE: I've added tests for that at https://github.com/kaliiiiiiiiii/Selenium-Driverless/blob/393d03cc7ba2cb3bb247c9f8f1ad4769ef2d5e1c/tests/html/test_relative_find_elem.py,, which also all pass
Thanks!
Works fine, BUT it's not working when I try to do this:
I'm only getting text from the first object in the list