Selenium Java - checking element and page source shows different infinity

I am trying to navigate pages using the selenium web driver, and I am stuck at one point please refer to the image where I showed the output of the validation element for this page I'm working on.

inspect element output

but in the page source (which I saw in the browser, and also using Jsoup) it looks like this:

<html> <head> </head> <frameset rows="75,60,*" resize="no" SCROLLING="NO" name=main border="0"> <frame src="/frame/topnewprof.shtml" name="top" SCROLLING=NO> <frame src="/frame/blank.html" name="menu" SCROLLING=NO > <frame src="/itrade/user/welcome.exe?action=chk_seckey_stat" name="body" SCROLLING=AUTO> </frameset> <body>&nbsp; </BODY></html> 

why is this a mismatch? and the yellow material that stands out in the image above has the element that I need! how do i get there using selenium ?? I know that we can go to the iframe using selenium switchTo().frame() , but even if I get into any of the three frames, as shown above, in the source information of the page, I can’t find the information I need, can is it to be achieved? is it possible?

UPDATE: Hi guys! I found a solution to this and now that the heap intersects. in fact, what happened when I tried to getPageSource, selenium actually received the frame source of one of the frames ("body" - as mentioned above), I accidentally realized this. Then, to solve my problem, I wanted to go back one step from where I was from, 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 the Selenium defaultContent () function and returned one step with switchTO (). frame () went into the frame of my desire and completed the task

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

+5
source share
3 answers

I found a solution to this and now, when it crosses. in fact, what happened when I tried to getPageSource, selenium actually received the frame source of one of the frames ("body" - as mentioned above), I accidentally realized this. Then, to solve my problem, I wanted to go back one step from where I was from, 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 the Selenium defaultContent () function and returned one step with switchTO (). frame () went into the frame of my desire and completed the task

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

0
source

I could not say exactly why this discrepancy was caused, but I have an idea how you could solve this problem.

I had similar problems with javascript phrases in pages. Typically, these items need to be clicked to enter. But if this element is not clickable or clicking is not the only problem, you can also search for the necessary information using the unique features of Xpath.

I'm not sure that you are already using the Selenium IDE, but perhaps you can record the navigation to this element and use the abandoned Java code from the Selenium IDE to get the required information.

... I only saw this problem when using Selenium remote control, not Selenium WebDriver ...

0
source

I think the problem can also be solved with xpaths. The easiest way to get the correct xpath is to use firebug with firefox. Right-click on an item in the developer tools and click copy xpath. Firebug is incredibly accurate when creating xpaths. He solved many problems like me.

* Even if you do not use firefox, most of the time you can use the same path from firebug in testing chrome webdriver.

It is a life saver.

A warning, although sometimes the path is long:

 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"; 
0
source

Source: https://habr.com/ru/post/1200272/


All Articles