1

I am having a problem using selenium and internet explorer 11. I have to automate a website data gathering project where I have to scrape the website for CSV links and download then automatically everyday.

The website is markets.midwestiso.org/MISO/.

You can't access this website as it requires a certification (which i have). According to miso, their website only works on internet explorer browser.

So I am restricted to using IE with selenium to do this. My problem occurs when I try to mouse over the "Settlement" tab, when doing this another submenu opens which is the "settlement info" tab and finally hovering over the settlement info tab opens up the view tab which I have to click.

Following is the website HTML code:

<html>
  <frameset name = "frameset" frameborder="no" noresize="">
    <frame name="nav" src="/miso/header/header.do;jsessionid=2d..!" frameboarder="no" no resize="" scrolling="no">
      <html>
        <body background = "/miso/images/hdrbackgroundslvr.gif >
           <table width ..>
           <div id="xclock1"..>
           <div id="tab1">
           <div id="tab2">
              <table width="115">
              <tbody>
                <tr>
                  <td class='normalHeaderTabs" id="tab2TableDetail" style="background: url ("https://markets.midwesiso.org/MISO/images/hdrTabNormal.gif");">..</td>
                     <p id="tab2_p" style="color: rgb(2555,255,255);" onmouseover="this.style.color=">Settlements</p
                  </td>
                </tr>
              </tbody>
             </table>
            </div>
    <frame name="ContentFrame"
     src="/MISO/common/blank.html;jsessionid=2bC6h1hLNJwrN..." frameborder="no" scrolling="auto">
        <html>
          <head>..</head>
          <body>
            <table witdh='735' ..></table>
            <div id='tab1flyover0" onmouseover='document.getElementbyID('tab1flyover0DivShim')
              <table width="160" cellspace="0" cellpadding="0">
                <tbody>
                  <tr>
                    <td aligh="left" id="tab2_tab2flyover0tableDetail0" valign="center" onclick='parent.frames[0].changeTopTabs('tab2TableDetail');parent.frames[0].changeContentFrame('/MISO/vss/view.do?cmd=view');">
                      <p id="tab2_tab2flyover0text0" style="color:black;">View</p>
                     </td>
                   </tr>
                 </tbody>
                 </table>
               </div>
            <div id="tab1flyover2" style="left" onmouseover='document..'
            <iframe id='tab1flyover1DivShim'>
            <div id="tab2" onmouseover='document.getElementById("tab2DivShim");document.getElementByid('tab2').style.visibility='visible';"onmouseout="..'
            <table width="160">
             <tbody>
               <tr>
                 <td height="20" id="tab2_tab2cell0"; onmouseover="document.getElementByID('tab2flyover0') onmouseout='document.getElementByID("tab2_tab2Cell0).style.backgroundcolor='#C0CoCo';document.getElementbyId('tab2flyover0').style.visibility='hidden'
                   <p id='tab2_tab2flyover0" >Settlement Info</p>
                 </td>
               </tr>
             </table>
            </div>

Now, how can I choose the "settlements" tab? I have tried this method and it works, but it creates problems down the road for me when I want to hover over the elements.

from selenium import webdriver
import os
import time
from selenium.webdriver.common.action_chains import ActionChains


#set directory where files will be downloaded
iedriver = 'H://work/IEDriverServer.exe'
driver = webdriver.Ie(iedriver) #establish internet explorer as website

#website where we download files from
url = 'https://markets.midwestiso.org/MISO/'
driver.get(url)
driver.switch_to.alert.accept()
time.sleep(5)

driver.switch_to.frame('nav')
settlements = driver.find_element_by_id("tab2_p")

driver.switch_to_default_content()
driver.switch_to_frame("ContentFrame")

settlement_info = driver.find_element_by_id("tab2_tab2flyover0")
view = driver.find_element_by_id("tab2_tab2flyover0text0")


actions = ActionChains(driver)
actions.move_to_element(settlements).perform() #this successfully goes to the settlements tab and hovers over it.  

driver.switch_to_default_content()
driver.switch_to_frame("ContentFrame")
actions = ActionChains(driver)
actions.move_to_element(settlement_info).perform()
#actions.click(view).

There is no error, but the mouse is not hovering over the "settlement info" and finally the "view" tab. Can someone please help?

When I type this:

actions.move_to_element(settlements).perform()

I can actually see the cursor hover to "settlements" tab, but then it disappears extremely quickly. Is there a way for me to make it stay and pause it between going from "settlements" tab and then to "settlement info" tab? Eventually i want to click on the "view" tab, but upon executing the above program, it executes, but i don't see any hovering happen especially on the sub-menus.

1 Answer 1

1

Try to wait for visible attribute of the required HTML element. Mouse over event seems only changes the visibility of the element to true, so wait in selenium till it happens.

So first you would set:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Then do something like:

wait.until(expected_conditions.visibilityOfElementLocated((By.ID, "settlement")

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.