source code of website differs from what is displayed

77 views
Skip to first unread message

eric aldinger

unread,
Aug 25, 2012, 1:14:41 PM8/25/12
to seleniu...@googlegroups.com
This may be more simple of answer than you are looking for, but this is the beginning. I use the Firefox add in Firepath. I walk through the user story or test case I want to automate. At each point I inspect the dynamic element in the state before and after I take an action that will effect it. I also use the Selenium IDE to walk through the test sometimes. I then export this in my language and pull out the elements and actions I need. I usually do this in Firefox, and then apply any tweaks need for multibrowser support.

Darrell Grainger

unread,
Aug 25, 2012, 4:55:17 PM8/25/12
to seleniu...@googlegroups.com
Are you using Selenium IDE to record and play back scripts? Or are you using WebDriver? If you are using WebDriver, which language?

I write my Selenium code using Java. If I have:

    WebDriver driver = new FirefoxDriver();
    driver.get("url of your website goes here.");

and the web page has frames, I need to switch to each frame to be able to access it. For example,

    System.out.println(driver.getPageSource());

will print the same thing you see when you do a "View Source" on the web page. If you want to see the source code of the iframe (or interact with it), use:

    driver.switchTo().frame("ITSFRAME1");

Now if you do:

    System.out.println(driver.getPageSource());

you will see the source code for the iframe. If you do any Selenium actions, they will apply to the iframe only. If you need to get back to the main web page, use:

    driver.switchTo().defaultContent();


On Saturday, 25 August 2012 08:04:30 UTC-4, micha182 wrote:
Hey guys,

Selenium really is a nice thing, but currently I am facing the following issue.

I am trying to automate some actions on a website that consists of three iframes.
Via Firefox the content of each of them is displayed correctly, there are divs, links, and many further elements visible.

But if I try to review the source code of this website none of these elements is available and as a consequence I cannot perform any selenium commands it.
<iframe id="ITSFRAME1" name= "itsframe1_20120825115757.1259930 "  noresize="1"  frameborder="0" framespacing="0" border="0"  onload="showIFrame(0);" src="about:blank" > </iframe>

My question now is: How can I make dynamically loaded content available?
I guess it cannot be too hard, since the Internet Explorer does display it in its sourcecode-view-mode.

Regards
Michael

eric aldinger

unread,
Aug 26, 2012, 12:25:30 PM8/26/12
to seleniu...@googlegroups.com
Michael - I also use C# in my project (and msTest and Webdriver. Let me pretend I have a page with questions and each question has has a set of answers with radio buttons. The first question is What is your sex? If you answer Male the content does not change. If you answer Female a new question appears asking Are you pregnant? I personally do not try to map all objects in the DOM to a class in my project at the time I execute my test. I create a class and map each object to a method in my project, that allows me to use it in my tests. To do this with the pregnancy question I will first answer the sex question, and then record the navigation to the pregnancy question. My method for the pregnancy question would either have something that verified the existance of the pregnancy question at run time OR change the answer of the sex question to female (depending on how I was going to use the element). Best practice is to use lazy loading to create the object so that I don't have to actually have it sitting around is an object memory without having to use it for the test. That is an idea I've yet to practice.

Olfi Oliveira

unread,
Mar 25, 2015, 5:22:41 PM3/25/15
to seleniu...@googlegroups.com, mich...@googlemail.com
In my case I have an iframe inside a div (attribute). How can I access to this iframe? I can´t see any element bellow this div.

What I see in the browser is:

<div id="WIN_0_304255502" arid="304255502" artype="View" ardbn="z2VF_02" 
        arcontainerid="304255802" arpercentwidth="100"
        arpercentheight="100" class="arfid304255502 ardbnz2VF_02"
        ardcf="1" style="top: auto; left: auto; width: 1318px;
        height: 744px; z-index: 1135; min-width: 20px;
        max-width: 32767px; min-height: 20px;
        max-height: 32767px; position: relative; overflow: hidden;
        background-color: transparent;"
        arvfframe="
<iframe style=&quot;top:0px&amp;#59; left:0px&amp;#59; width:1170px&amp;#59;
       
height:744px&amp;#59;
       
background-color: transparent&amp;#59;&quot; name=&quot;VF304255502&quot; frameborder=0
       
scrolling=&quot;no&quot;
       
allowtransparency=&quot;true&quot; arviewbordercolor=&quot;null&quot; title=&quot;z2VF_02&quot; src=&quot;javascript:&amp;quot;&amp;lt;HTML&amp;gt;&amp;lt;/HTML&amp;gt;&amp;quot;&quot;
       
onload=&quot;DVFol&amp;#40;&amp;#41;&quot;>
       
</iframe>
        " arwindowid="0" arstop="1">

        //more elements

Thanks

Reply all
Reply to author
Forward
0 new messages