0

Im unable to access the "view profile" element from the preview page opened while scraping the sciencedirect website using selenium in python. Is there any way to access the elements in the preview page.

driver.get("https://www.sciencedirect.com/science/article/pii/S092911991930940X#!")
driver.find_element_by_xpath('//*[@id="author-group"]/a[2]/span').click()
driver.find_element_by_xpath('//*[@id="profile-preview-page"]/div/div/div/div[2]/a').click()

the error im getting is enter image description here

6
  • what element You try to click by profile-pre...? I don't see this id in page code. Commented Jan 23, 2020 at 10:01
  • I think your xpath is not correct, check it Commented Jan 23, 2020 at 10:01
  • @ZarakiKenpachi after clicking on one of the authors name there is a preview window opening at which has further information about the author. You can see the page code after clicking on the author's name Commented Jan 23, 2020 at 10:30
  • @EvgeniyChiruk im pretty sure im giving the right xpath. its not just the view profile option, i couldnt interact with any other element in the profile preview page Commented Jan 23, 2020 at 10:31
  • @VenuBhaskar what information you need from this panel? Commented Jan 23, 2020 at 10:43

1 Answer 1

1

You need to switch in the iframe before searching for an element in it, as here:

iframe = driver.find_element_by_xpath('//iframe[contains(@title, 'Author Profile')]')
driver.switch_to.frame(iframe)

And then you can click:

driver.find_element_by_xpath('//*[@id="profile-preview-page"]/div/div/div/div[2]/a').click()
Sign up to request clarification or add additional context in comments.

1 Comment

im getting the following error "InvalidArgumentException: Message: invalid argument: invalid 'id' " while using driver.switch_to.frame(iframe)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.