1
<html>
<frame src="/mts.web/Menu_big5.aspx" name="leftFrame2" scrolling="no" noresize="">
    #document
        <!doctype html PUBLIC "-//W3C//DTD MTML 4.01 Transtitional//EN">
        <html>
           <Head></Head>
           <Body>
                <table>
                     <tbody>
                          <tr>
                             <td>
                                <a href="javascript:inputOrder('B')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','images/btn/buy_on_b5.gif',1)">
                                <img src="https://bss2.bsgroup.com.hk/mts.web/images/btn/buy_b5.gif" name="Image2" width="92" height="20" border="0">
                                </a>
                             </td>
                          </tr>
                     </tbody>
                </table>
           </Body>
        </html>   
</frame>
</html>

How do I use driver.find_element_by to click the button inside <td>...</td>

I tried to copy the xpath of the button I said above using chrome and run it using driver.find_element_by_xpath but no action after I put it in score.

Please if someone know how to do it, teach me please.

1

1 Answer 1

1

Try This:

driver.switch_to.frame(driver.find_element_by_name("leftFrame2"))
#Now Execute Your code Here
#After that add this line
driver.switch_to.default_content()

for frame you need to switch on that and then switch back

Sign up to request clarification or add additional context in comments.

1 Comment

Thank You!.. it works!! It will pop up a new window but I can not switch to the new window and input stuff by using driver.switch_to.window(driver.window_handles[2]) to switch on it. Do u know how to do it?

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.