1

I am working on this website Basically I want to capture 2 latest news from News section that is below the table and store that news in some json and collect picture if possible but I am not able to go to the news section as It always raise error saying

selenium.common.exceptions.ElementClickInterceptedException: Message: Element <a id="ctl00_ContentPlaceHolder1_CompanyDetail1_lnkNewsTab" href="#divNews"> is not clickable at point (307,786) because another element <iframe id="webpush-onsite" name="webpush-onsite"> obscures it

here is some part of code I tried tough

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
stocks_data = ["AKPL","NICA"]

for stock_data in stocks_data:
     self.driver.get(f'https://merolagani.com/CompanyDetail.aspx?symbol= 
      {stock_data.lower()}')
      self.driver.find_element_by_xpath("//li[@id='navNews']"
                              "//a[@id='ctl00_ContentPlaceHolder1_CompanyDetail1_lnkNewsTab']").click()
lord stock
  • 1,191
  • 5
  • 32

1 Answers1

1

If you really need to click it regardless a normal user won't be able because as the error says, there's an IFrame on top of it...

Try the following:

  1. Set the window size to 1920x1080 or so, maybe the elements overlap because the screen on Selenium's session is too small ‍♂️

  2. Worst case scenario, inject some Javascript code to do it forcefully:

self.driver.execute_script("document.getElementById('ctl00_ContentPlaceHolder1_CompanyDetail1_lnkNewsTab').click()")
  1. Click on exact coordinate (x,y) if you know it ofcs.
EvgenyKolyakov
  • 3,310
  • 2
  • 21
  • 31
  • 1
    thanks for answer but can you help me get further from there as I am not able to get those news as I want news in json form – lord stock Jun 27 '22 at 03:48
  • I think it'll be a bit annoying in this format, hhh. Maybe just ask a new answer, because it's already kind of a different topic, with what you get, how you get it and what do you expect. (then maybe just ping me on that question, I'll try to help me best ^_^) – EvgenyKolyakov Jun 27 '22 at 08:21
  • 1
    hi @Evgeny I have added new qsn https://stackoverflow.com/questions/72774792/selenium-unable-to-process-further-after-executing-script – lord stock Jun 27 '22 at 15:40
  • @nava, see answer - https://stackoverflow.com/a/72775070/2124529 :) – EvgenyKolyakov Jun 27 '22 at 16:00