1
votes

I would like to be able to get the source page of the link I got from a a href without making Selenium changing page.

I am getting the a element using

driver.find_element(By.XPATH, "//a[contains(@class, 'css-1xyedec e1pf1lj70')]")

Then I can get the link in the href using

elem.get_attribute('href')

But I cannot find a way to get the source page of the link using selenium without changing the page of the browser.

EDIT: Here is the website on which I am trying to do it. The <a> is located for each sale in each div that includes the photo and the part with the title, price...

1
You could open a new tab with that link and than use driver.page_source the close it. - Arundeep Chohan
This class seems to be dynamic: e1pf1lj70. Add html cod please. - vitaliis
@ArundeepChohan I will maybe do like this if there is no better solution. - Mickaël
@vitaliis I just updated the question. - Mickaël
after you get href of the page try to get HTML with requests library if it's not dynamic html = requests.get(url) - Giorgi Imerlishvili

1 Answers

0
votes

Check this answer https://sqa.stackexchange.com/questions/17022/how-to-fill-captcha-using-test-automation . You cannot automate captcha. You should ask dev team for a workaround. I would ask to disable CAPTCHA in test environment. It is no sense to have it there.