i have the following script that given x,y coordinates and a url returns the link of the element in these coordinates:
def get_link(url,x,y):
DEFAULT_CHROME_WINDOWS_SIZE = '1024,2160'
Options = ChromeOptions()
Options.add_argument("--headless")
Options.add_argument('--window-size={}'.format(DEFAULT_CHROME_WINDOWS_SIZE))
driver = webdriver.Chrome(options=Options,executable_path="/usr/lib/chromium-browser/chromedriver")
driver.get(url)
time.sleep(3)
elem_by_coords=driver.execute_script("return document.elementFromPoint(arguments[0], arguments[1])",
x, y)
link=elem_by_coords.get_attribute("href")
return elem_by_coords.aria_role,link
for the following input:
elem_type,link=get_link("https://workflowy.com/s/aunt-sparkies-inc/JVbOUV2xLta97A77",448.5,413.5)
i get as expected:
elem_type=link
link=https://u.to/QM6CHA
However, for the following input:
elem_type,link=get_link("https://indd.adobe.com/view/72dacb55-647a-49ba-838b-8e82de10290a",482.5,1179.5)
i get this output:
elem_type=Iframe
link=None
the problem is that the link of the element is inside the iframe. i am certain that these coordinates match the element with the href link i want to extract but as i mentioned because it is in an iframe for some reason it takes the iframe and not the element inside the iframe..
so my question is how can i get the element at a certain x,y position that is inside the iframe?