I am using Selenium IDE to test a tree.
I am having two elements with same parent element, one is a check box and the other is a text.
My question is, can I use the text element to make selenium click on the check box?!
in another way, can I connect the two elements to each others some how?!!
As for me I am right click on the browser webpage that I want to test. And I can easily chose by show all available command. Note that when you right click on the browser you need to open your selenium-ide.
Hope this will helpful.
Related
I am trying to get some elements with python selenium.
When I inspect, I make a right-click on the element of the page and it shows the code in the dom.
So I successfully identify the correct XPath.
But then, when I execute my python selenium script, it doesn't detect the nodes.
So I had a second look at the dom and I can see the nodes are hidden. They only show when I made an inspection on it.
Please look at this screenshot:
You can see in grey all the hidden elements.
Does anyone already face this scenario? How can I get these elements when they are hidden? is there a hack?
The "hidden" elements are script blocks. So you can't click on them as they are not part of the UI of the page, they are part of the logic. A script is just not clickable, it has no size, no color and no position.
I want to use XPath expressions in Selenium code, but I don't know how to get it from a site's HTML code.
I'm using the Google Chrome web browser.
The easiest way is to inspect the element you want to get the XPath expression for. Then click on the highlighted code and Copy → Copy XPath which give you a full XPath patch you can copy to your code.
For Firefox, you should install Firebug or another extension like this.
As neliCZka suggests, you could also try to build a relative path if its possible by trying to find the proper XPath in the search bar in Chrome after inspecting the element.
I see that someone has downvoted the suggestions to use the Copy XPath option from different inspection tools. That's probably because these paths can often be difficult to maintain as the application changes, won't work in Selenium because they're not sufficiently unique, or can just be unreasonably complex for complex HTML.
Copy XPath... is useful as a starting point though. If you're not familiar with XPath, this tool can help you to get a better feel for how to apply it to your HTML content, but it's very important to learn how to use XPath yourself.
Right click on the element you want to have an XPath expression for, and then click Inspect Element. A new frame will open with the HTML source code.
Now right-click on the code and select "Copy XPath".
Note: you will have to remove " WITH ' after copying it into your code
Install Firebug for Firefox. ...
Open the website that you want to inspect. ...
Click the Firebug button. ...
Click the element inspector button. ...
Click the web page element that you want to inspect. ...
Right-click the highlighted code in the Firebug panel. ...
Select "Copy XPath" from the menu.
You can press F12 to get the check page, select your hoped HTML code, and hit the mouse 2. It has the copy option, and there is a copy XPath.
I am new to selenium. Is there anyway i could test if an element, for example an edit buttons is present in a page. There are multiple edit button and they all have different Xpath positions. Will it work if i use verifytext and give the value as "Edit"?
Is there a way for me to select an element in a web browser, using Selenium IDE and get an XPath of the item I clicked on (regardless of whether it is text or button?)
TIA
There is no such thing as "the" XPath. Every element has many Xpath, there is no definitive.
Some Xpath are brittle, some are stable, some are reliable, some are unstable.
The "best" and most suitable has to be a human decision. Browsers allow you to test and experiment with Xpath.
You can get "the" xpath - but it would be an absolute path to the element which is usually not reliable and very fragile. In the firebug firefox extension find an element and select "Copy xpath" from the menu.
In Selenium IDE, click the Select button beside the Target text box. And then move your mouse pointer to the web element that you want to check (it will be highlighted). Click on the element. In the IDE, click the Target dropdown box. Select the xpath that you want to use.
Alternatively, if you do not want to use IDE, you can also use the Developer Tool panel in Chrome or Firebug plugin in Firefox to get the xpath.
In Selenium IDE, by keeping the recording mode on, then clicking on the element you want to capture, you can find all the locators of that web element that are captured by the Selenium IDE (if the selenium IDE is able to capture the web element). After recording that element in IDE , click on the drop down in the Target bar (on right end of Target bar), you will find all the locators including xPath (css as well).
I am using the Selenium IDE extension for testing webpages in FireFox and I was able to find out how to perform almost every command that I need to automate testing for my webpage.
Unfortunately I was not able to find out how to do this through the list of commands that you can manually enter into the queue of Selenium IDE.
I was wondering if anyone knew how to do this in the Firefox extension. Thanks!
You can use dragAndDropToObject command which locates the target element and drags it to the centre of the destination element.
dragAndDropToObject
target: locator of the element to drag
value: locator of the destination element
There is also a dragAndDrop command which drags the element by specified amount of pixels and drop it.
For one thing, you might want to use Selenium Builder instead of Selenium IDE. Also, there are some things that Builder or IDE cannot record, such as iFrame interactions, certain AJAX actions, and also drag and drops. For those, you need to code them by hand afterwards and get them working.