in Education by
After reading the switch-to-iframe documentation, I am still not sure what will driver.getPageSource() return after driver.switchTo().frame(frame element) is called. By Page source, I refer to the definition in getPageSource(). But I can't find anything that confirm src's attribute is the same as page source. I think during the switching, webdriver will send a request to the src url and use the response to create a page source for the iframe, is it correct? Is an iframe src's attribute the address for storing its page source? In here, it says The src attribute specifies the address of the document to embed in an iframe. (1) Anyway, let's say if we have an iframe like below #document ----> may or may not exist, not sure if #document create by src or not When the driver switch to this iframe, Is the "/video.mp4"'s content use to create the iframe's page source (I think page source is the #document)? But this is a video file, how is it possible to use a video as page source (html)? Or the page source is "/video.mp4"'s conetent + #document? (2) What if the iframe has a html as src, such as #document ----> may or may not exist, not sure if #document create by src or not Does the page source become whatever is in file.html PLUS the #document in iframe? Or the #document will only be created using the content from file.html after driver is switch? (3) If the iframe has no src, such as Can the iframe still has page source? What will getPageSource() return in this case after driver switch to this iframe? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
getPageSource() gets the source of the last loaded page which is actually the source of the current page. The page source returned is a representation of the underlying HTML DOM. Where as iframe is a construct which embeds a document into an HTML document so that embedded data is displayed inside a subwindow of the browser's window. This does not mean full inclusion and the two documents are independent, and both them are treated as complete documents, instead of treating one as part of the other. The src attribute specifies the address of the document to embed in an iframe. Syntax: Attribute Values: Value Description URL Specifies the URL of the document to embed in the iframe. Possible values: An absolute URL - points to another web site (like src="http://www.example.com/default.htm") A relative URL - points to a file within a web site (like src="default.htm") This usecase Considering the HTML: #document ----> may or may not exist, not sure if #document create by src or not Here video.mp4 is the file within the web site which will be embedded within the frame and you can access once you switch to the frame element. Update Once you switch to the desired iframe you can again use getPageSource() to extract the DOM Tree of the iframe element.

Related questions

0 votes
    Quick Summary of my question: Does Gulp 3.6.0 dest() handle glob-base the same way as 4.0.0? ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I've had several occasions in my selenium tests where I decided to use Selenium's click_and_hold() (source ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
0 votes
    What is the solution to the absence of a script tag without an src attribute? (a) Resend the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    Which of these values is returned by read() method is end of file (EOF) is encountered? (a) 0 (b) 1 (c) ... I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    What is the range of numbers returned by Math.random() method? (a) -1.0 to 1.0 (b) -1 to 1 (c) ... util - More Utility Classes of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these data type is returned by every method of OutputStream? (a) int (b) float (c) byte ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
0 votes
    What is the range of numbers returned by Math.random() method? (a) -1.0 to 1.0 (b) -1 ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    What is mean by 'src refspec master does not match any when pushing commits in Git?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    I am trying to scrape the data off the webpage below, using Selenium in Python 3: https://www. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I am trying to scrape the data off the webpage below, using Selenium in Python 3: https://www. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    Which of the following attribute takes the source of the PHP file? (a) img (b) src (c) source ( ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
...