Selenium Java - inspect element and page source shows different infiormation Selenium Java - inspect element and page source shows different infiormation selenium selenium

Selenium Java - inspect element and page source shows different infiormation


I couldn't exactly tell you why this mismatch is caused but I have an idea of how you could solve this problem.

I had similar problems with javascript phrases on pages. Normally such elements have to be clicked to get into. But if this element isn't clickable or a click doesn't sole the problem you could also search the information you need by using unique Xpath's.

I'm not sure if you using Selenium IDE already but maybe you could record navigating to this element and use the thrown java code from the Selenium IDE to get the required Information.

... I only have seen this problem while using Selenium remote control not the Selenium WebDriver...


I think the problem could also be solved by using xpaths. The easiest way to get the correct xpath is using firebug with firefox. Right click on the element in developer tools and click copy xpath. Firebug's incredibly accurate when producing xpaths. It has solved many problems like that one for me.

*Even if you aren't using firefox, most of the time you can use the same xpath from firebug in chrome webdriver testing.

It's a life saver.

Warning though, sometimes the path is long like:

final static String planTitlePath = "/html/body/div[1]/div[2]/div[1]/div[2]/div[5]/div/div/div/div/section/div/div[2]/div/ol/li/div[1]/plan-card/h4/span";


i found the solution to this and now that huddle is crossed. actually what happened was , when i was trying to do getPageSource, selenium was actually getting the frame source of one of the frames ("body" - as mentioned above), i accidentally figured that out. Next to solve my problem i wanted to come one step back from where i was so i can select this iframe = (name="top") which was the target where i had the content as shown in the image. to Achieve this i used Selenium's defaultContent() function and came back one step then with switchTO().frame() went into the frame of my desire and accomplished the task

hope this helps!! and thanks for everyone who tried to help me on this.