How to pass text to an underlying iframe where an input reflecting iframe itself and have no input? - selenium

How to pass text to an underlying iframe where an input reflecting iframe itself and have no input?
Using Selenium or robot framework
Please find snapshot of html code

Related

Unable to get specific element on a page, using xpath for a Selenium script

enter image description hereI am having difficulty locating input fields on a form, that has another component embedded.
I can navigate to the beginning of the component, but am unable to locate anything inside the component, using xpath , css location etc...
Even if I inspect the element in chrome, and copy its xpath or css (right click, copy xpath/ selector) and try that path , the element is not found.
There is a #shadow-root element, which I think may be causing the issue ?
See screenshot of where I can locate beginning of component, the selector i am using and the input field i would like to locate
Any ideas/suggestions very welcome
enter image description here

Get the xpath of an element inside an iFrame for RobotFramework RIDE

I am trying to get the xpath of a 'Form' element by its id that is inside an iframe.
In chrome xpath plugin when i query
//iframe[contains(#id,'fraModalPopup')]
it gets me the iframe but when i try to get anything down the hierarchy it just returns null. e.g. if i try doing
//iframe[contains(#id,'fraModalPopup')]/html // returns null
or
//iframe[contains(#id,'fraModalPopup')]/form[contains(#id='aspnetForm')]
// not sure if it is a right xpath statement - also returns null
would please anyone guide me how I can get hold on to the form element? I have to use this xpath inside RIDE (Robot Framework).
iframe is an element inside main HTML DOM that contains its own embedded HTML DOM. You don't need to use iframe as context node to find form inside frame, but you need to switch to that iframe
select frame id=fraModalPopup
to be able to handle elements inside embedded HTML DOM (no need to add "//iframe" to XPath)
xpath=//form[#id='aspnetForm']

How to get Inspect Element code using Selenium WebDriver

I'm working in selenium with Firefox browser.
The Html code shown in View Source (CTRL+U) is different from the html code i see when inspecting the elements in Firefox.
When i run the driver.getPageSource() i only get the View source (CTRL + U) codes.
Is there is any way to access the Inspect element code instead of View source code?
I think your question is answered here.
The View Source html is what is sent by the server. I think of it as compile time html, or the initial state of the DOM.
The Inspect Element html could have been updated by ajax responses or javascript so will not necessarily be the same. I think of it as runtime html, or the current state of the DOM.
The GetAttribute() method queries the current DOM element state. You can return a particular html attribute value directly
webElement.GetAttribute("class")
or get the whole html string.
webElement.GetAttribute("innerHTML")
There are some fundamental difference between the markup shown through View Source i.e. using ctrl + U and the markup shown through Inspector i.e. using ctrl + shift + I.
Both the methods are two different browser features which allows users to look at the HTML of the webpage. However, the main difference is the View Source shows the HTML that was delivered from the web server (application server) to the browser. Where as, Inspect element is a Developer Tool e.g. Chrome DevTools to look at the state of the DOM Tree after the browser has applied its error correction and after any Javascript have manipulated the DOM. Some of those activities may include:
HTML error correction by the browser
HTML normalization by the browser
DOM manipulation by Javascript
In short, using View Source you will observe the Javascript but not the HTML. The HTML errors may get corrected in the Inspect Elements tool. As an example:
With in View Source you may observe:
<h1>The title</h2>
Whereas through Inspect Element that would have corrected as:
<h1>The title</h1>
getPageSource() always returns the markup obtained through View Source.

Testing embedded HTML form via Selenium IDE

I have an html page that has a small piece of JavaScript that further embeds an HTML form in a div tag (this div is identified by an ID).
I want to use Selenium IDE to test the form. I recorded a basic test to test the embedded form but Selenium seems to be failing. It cannot find the elements or the text.
I got the source of the parent html page but it does not have any Form html. Firefox allows you to see the Form html by going to 'This Frame->View Source'. The embedded html is whole html page not just the form - I mean it starts and ends with <html> tag
I was wondering how could I test the embedded form using Selenium IDE ? I searched a lot and found 'SelectFrame' but all the examples on the web include Java code (that I do not wish to get into) as opposed to plain HTML (I would like my test to be plain HTML Selenium test cases and would like to keep it simple).
Also, I doubt if 'SelectFrame' is going to help as the form gets embedded in a 'Div' tag and not in the frame.
Any help is greatly appreciated.
Thanks
you have a frame and frame have some name, please use this and let me know
selectFrame | frame name |
verifytext | text
selectWindow | null - this for release the frame
please show me once your script so that I will help you futher
use
driver.switchTo().frame("marco");
replace "marco" with your own frame name

Selenium - How to match image presence and location on page

My query is that - I have my images on webpage- a logo or say navigation bar i can store as an image. Can i test using selenium presence of these images on a webpage when loaded along with the position of the image on page.
What my issue is that i need to actually look at image objects in HTML and also may be images not in HTML but they are partial screenshots of webpage which i want to match. This test will help me pick alignment issues - in case my navigation bar is now going to second row i can match with previous stored image to check.
Thanks
VB
An example on how to check if a particular image is present:
In this page:http://www.google.ie/firefox?client=firefox-a&rls=org.mozilla:en-US:official
Selenese command
Command: verifyElementPresent
Target: //td/table/tbody/tr/td/table/tbody/tr/td/img[#src='/images/firefox/Fx4Launch.png']
Hint: If you want help to get the XPath for a particular element I recommend you using a plugin like Firebug (http://getfirebug.com/)
Put an extra "\" in the beginning of the xpath copied by Firebug, otherwise selenium do not find the element.
You can verify that an image is at a location like so:
verifyElementPresent //div/p/img
This example uses XPath to locate an <img> element that follows a <div> and <p> tag.
But verifying that a screenshot is the same as the rendered page? You're talking about a completely different problem, which is image recognition. Selenium is a tool for automated acceptance testing.