There's an earlier post about this, but I'm not having luck with the solution. I'm trying to grab the duration of a video, which I believe should be the class ytp-time-duration, but I'm not getting anything. Anyone have any insight?
Thanks!
The duration is in a span with the class attribute value ytp-time-duration, which you can select with the following XPath:
//span[#class="ytp-time-duration"]
One easy way to obtain an XPath to select an HTML element is to:
open the developer toolbar in Chrome
click the inspect element button
hover over the duration and then select it by clicking on it
it will highlight the span in the HTML view in the toolbar.
then, right-click on the highlighted HTML in the developer toolbar and select Copy -> Copy XPath,
which will produce an XPath like this:
//*[#id="movie_player"]/div[24]/div[2]/div[1]/div/span[3]
or right-click and select Copy -> Copy selector in order to produce a CSS selector:
#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > div > span.ytp-time-duration
Related
I want to click on this element:
<a id="welcome" class="panelTrigger" href="#">Welcome Admin</a>
but I am not able to locate this element.
I have tried:
id=welcome, xpath=//*[#id="welcome"]
Click Element or Click Link but it is not working. Can you please help me?
I think you should be fine any of the lines below:
Click Link id:welcome
Click Link Welcome Admin
Based on the documentation:
When using the default locator strategy, links are searched using
id, name, href and the link text.
So if the ID does not happens to be unique you can still refer to the link by its text.
Try this way
Scroll To Element xpath ${element_locator}
Wait Until Element Is Visible ${element_locator} timeout=30s
Click Element ${element_locator}
Using Chrome, I can get the path to an element. I select "View source" and then right-click on the relevant item and say "get XPath".
In Safari, I can view the source, and when my cursor's on an element in the source, I can see the xpath visually displayed as a list of elements.. but I can't find a way to get the text for that xpath. Surely there's some way (he said optimistically).
This turns out to be easy, and I don't know why I didn't see it. In Windows at least:
Ctrl-U to display page source (or right-click on the page and click "View page source" in the popup menu).
In the page source, right-click on the element you like; in the resulting popup, click the "Copy >" option
Select "Copy XPath" from the resulting nested popup.
See picture below for an illustration. Everything was done with right-clicks.
Kinda late with an answer, but you might want to consider ios-webkit-debug-proxy by google.
Here is a good Extension for Safari and Google Chrome:
https://github.com/sergeche/xmlview#readme
Safari Extension: http://files.chikuyonok.ru/xv/xv.safariextz
Google Chrome Extension: download
Current features
Collapsable elements: Alt+click to expand/collapse all descendant elements
Outline for better document overview
Search by name or XPath. By default uses simple search mode which looks for a partial match in element‘s or attribute’s name; use special symbols like ‘/’ or ‘[’ to search by XPath
Quick XPath mode: hold down Command (Mac) or Ctrl (PC) key while moving mouse cursor over element‘s or attribute’s name to enter Quick
XPath mode. Use Shift key to cycle through available XPath variants
and then drag’n’drop element under cursor into text editor. Google
Chrome users: click on element will copy XPath to clipboard
I'm using the Firefox DevTools and I'm using the Inspector tab, in which it displays the HTML tree.
When I use the Search HTML feature, it only searches tags. So suppose I have this:
<div class="lol">textinsidediv</div>
And when I search for 'div', it returns the <div> accordingly. However, if I search for 'textinside' it doesn't match the text inside the content despite the fact that it's starting right there.
My question: How can I search for any arbitrary string within this HTML tree?
(In contrary Firebug performs a simple text search just as expected.)
The search in the Inspector panel of the Firefox DevTools allows to search for text content since Firefox 45 (see bug 835896).
Btw. since Firebug 2.0 you're also able to search in the HTML panel using CSS selectors (additionally to the plain text search).
It is not some really useless html tag search, it actually searches CSS selectors (same as what you use with css, querySelector in Javascript, or jQuery selector)
So you can search #id, go through all elements of a certain class by searching .class, you can even search for all elements with attribute including text, for example [class*="o"] should give all elements with letter o in class attribute. This is helpful for what designers/developers want to find - to find text, you can Ctrl+F within the page, then right click, inspect element.
A good idea is to Copy Inner HTML but even better is Edit As HTML. That brings up an in-place panel displaying the full text, and it can be searched with Ctrl+F or cmd+F.
Ctrl+G to find next, Ctrl+Shift+G to find previous.
Workaround: in the inspector, right-click the outermost tag, then click 'Copy Inner HTML'. Paste in a word processor and search there.
This is now fixed as of FireFox 45...
https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_HTML#Searching
See answer.
As an alternative to searching within dev tools...
Right click on the page anywhere
Select View Source
Within the source view you can easily perform a text search by doing a ctrl/f or cmd/f if on a mac.
I have a <div id="abcd"> which is changed by other code, I want to find out who is chaning that, can I set up a watch expression so that I can catch it in FireBug?
Thanks.
Bin
Using Firebug 1.5 or 1.6, use the Inspect to select the element, then in the HTML panel, right click on the element and select eg break on attribute change or another one as you need.
See http://getfirebug.com/doc/breakpoints/demo.html
i don't know the exact wording in english, i use it in german. But if you click right on your div, there is a function called "explore element" (normally at the bottom of the context menu). Afterwords firebug displays that area where you can see all live changes...
I'm having trouble with my xpaths in the Firefox plugin. I have three textboxes, the first one has ID=login and the rest has dynamically generated IDs. The first one works fine to write in the plugin, //input[#id='login'] but as soon as I try something more advanced, it cannot find anything. After reading plenty of forum posts, I've tried the XPather plugin to generate the xpath codes but the long html/css-filled strings don't work either. In some threads, people write "xpath=//..." and I tried that too, to no result.
Thankful for all help possible!
//M
The two tools I use are Firebug and XPath Checker, both Firefox add-ons.
In Firebug, select the HTML tab, right click on the element and select "Copy XPath"
For XPath Checker, right click on the element in the page and select "View XPath".
You can check this by pasting the result into the target field of Selenium IDE and then clicking the "Find" button. This tells what the Selenium result is going to be (much faster than having to run the test over and over!)
I've found that you have to "massage" the result somewhat e.g.
If you go to the Google home page and look for the "Images" link at the top left, the XPath Checker gives the image XPath as:
//id('gbar')/x:nobr/x:a1
This throws an error:
[error] locator not found: //id('gbar')/x:nobr/x:a1, error = Error: Invalid xpath 2: //id('gbar')/x:nobr/x:a1
If you remove the id e.g
//x:nobr/x:a1
you'll notice that the image has a green box around it showing thet the IDE has correctly parsed it.
Alright, I found some new information and it does work with writing "xpath=/" and the auto-generated codes from XPather. Although, the xpaths are very long and rely a lot on the HTML tags staying the same.
Does anyone have a better idea for xpath expressions (or css expressions) to write in order to enter information in the following three textbox elements:
TEXTBOX 1
Firebug: input type="text" tabindex="110"
name="6011300f91d9f186d1b7ab1a034827da"
id="input1"
Working xpath in Selenium, retrieved from XPather:
xpath=/html/body[#id='fire']/form[#id='loginForm']/div/div/div[#id='container']/div[#id='content']/div[#id='contentPadding']/div[1]/fieldset[1]/input[#id='input1']
TEXTBOX 2
input type="password" tabindex="110"
name="0de4766295b7a965fc4969da3df6824ba"
xpath=/html/body[#id='fire']/form[#id='loginForm']/div/div/div[#id='container']/div[#id='content']/div[#id='contentPadding']/div[1]/fieldset[2]/input
TEXTBOX 3
input type="password" tabindex="110" class="last" name="6c4e0fcde65e258c3dc7c508a1cc666a"
xpath=/html/body[#id='fire']/form[#id='loginForm']/div/div/div[#id='container']/div[#id='content']/div[#id='contentPadding']/div[1]/fieldset[3]/input
//M