Access to objects in a frame on a web page


D

Ddp Ludo

Hello,

I am trying to program a robot which will allow me to test whether a default password has been changed on my intranet servers .

And I 'm stuck since 2 days ...

HTML structure of the page:

<HTML>
<HEAD>
<frameset>
<frameset id=frmSet>
<frame name=frameMain>
<html>
<head>
<body>
<input id="username">

I try to go to fill the username field and I turn around because of the frames.

I tried to do it with mechanize . But as we can see, there is no body in the web page, so I can not instantiate the object form and get the fields on the page via this method.

I can directly open the htm page where username and the enable button , but it does not work . It lacks all parent functions to actually start the identification.

Here is the beginning of my code works . It connects to my page and correctly returns me the source code.

br = mechanize.Browser ()
br.set_all_readonly ( False )
br.set_handle_robots ( False ) # ignore robots
br.set_handle_refresh ( False ) # can sometimes hang without this
br.addheaders = [( 'User - Agent ', ' Firefox' ) ]
url = " file :/ / / root/Prog/html/AC1.htm "
response = br.open (url)
response.read print ()

Then, searching the internet, it seemed to understand that the frames were referred by links () class

lnkList = []
br.links for lnk in ():
lnkList.append ( lnk.url )
print " links " , lnk.url

It correctly list my links.

But can not use follow_link ( ) find_link .... I can not do it .... impossible to reach my username field ....

After the best , I can get the pointer of the frame object, but I use mechanize no more ....

frame = sys._getframe (2)
print frame

Does anyone know a solution?

Either using code or in my thinking and my approach to the problem.
Excuse my poor english.

Thank you in advance .
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top