I'm using XPath to identify the elements on a web page. Using the id attribute won't work as the id values are auto-generated and can change.
I want to know how I can access elements with display: none; style using following XPath expression?
//*[#id="main-content"]/div[1]/div/div[1]/iframe
I tried following one, is that right?
#//*[#id="main-content"]/div[1]/div/div[1]/iframe{display:NONE}
Related
I want to select the text "Auto-Publish" in Span. How can I do it with a CSS selector? with Xpath I know how to do it. I am using Nightwatch for UI automation. I want to make a generic function in the page object which will take a value as a parameter.
SelectFilterValue(value){
.click(`//span[text()="${value}"]`)
}
I can't do it like this since it's an XPath and I have to specify that it's an XPath. If it was a CSS selector I could do it since I don't have to specify that it's a CSS selector. Or is there is any way that I can do it with Xpath too?
CSS does not have any method like text. So in HTMLDOM, it is not possible at this point of time to locate the element based on text.
Moving further, You could do below in nightwatch.js
.useXpath().click('//span[contains(text(), "' + desiredText+ '")]')
and before calling this assign Auto-Publish to the desiredText variable.
Give a specific id to span tag and then edit css. You can also use inline css which will be the best option.
<span style="color:blue;">
".ngx-datatable datatable-header{
overflow: visible !important;
}
.ngx-datatable {
overflow: visible !important;
}"
I have two ngx datatables in two different pages,And I set customized filter in one datatable header by an filter icon, Problem is the dropdown of onclick of icon is cutting the dropdown,for that I googled and got to know that its an CSS issue and can be handled. So i written the following in my Angular SCSS file for one component related.
Using this working but impacting on other ngx datatables.
Help or suggest me any one on this.
Aren't they both having separate CSS files? If that is the case, it shouldn't be affecting one another. If they are both having the same CSS file as the style sheet, provide an ID to each table and provide the same id in the CSS as well, so that the specified style gets added only to that Id.
Once you specify the ngx-datatable styles under the respective Id's, it should work.
Let me know if it worked.
So I'm using Mechanize in Ruby to do some website scraping and want to find all nodes with a specific style attribute.
I want to return all nodes with a style attribute that has specific top value on the webpage.
The HTML will look like this:
<div id="c11285" style="position:absolute;top:1px;left:333px;width:65px;height:226px;overflow:hidden;background-color:transparent;z-index:10;border: 1px solid #000" onclick="">
In this case I cannot use the id, because each variation of the page has different ids so I want to search by the top value in the style attribute which in this case is 1px.
I've tried using webPage.search("div['style=top: 1px;']")
However, this does not work as px seems to cause an error.
Any suggestions on how I could achieve this or is this even possible?
It scans all elements and return those which have top:1px in style attribute.
//*[contains(#style, 'top:1px')]
I am using the Twitter Bootstrap Affix JS component. My UL list is affixing properly when I scroll the page down. Also - when I click on the individual list items (much like Twitter does on its docs page), it scrolls down to my anchor ID in my document, but the LI element does not receive the Twitter 'active' class. Nor does it get the 'active' class when I scroll my document.
I would expect the appropriate link to be active when I have scrolled to the particular part in the document (much like scroll-spy works), but I can't seem to get this to work.
Is there something special I need to set up so that Bootstrap will add the 'active' class when appropriate?
Yes, you need to also use the ScrollSpy plugin. You can activate it through markup or through JS. Letting #scroll-pane be the element that triggers scroll events and #navbar be the element containing the ul.nav, the following should get it working:
HTML
<div id="scroll-pane" data-spy="scroll" data-target="#navbar">
JS
$('#scroll-pane').scrollspy({target: '#navbar'});
Use either the HTML or the JS, but not both.
Additional Info
When the ScrollSpy plugin is passed a target, like scrollspy({target: '#navbar'}), this is used to construct a selector of the form
target + ' .nav li > a'
which, in this example would give
'#navbar .nav li > a'
It is important to understand the stipulations that this selector creates.
The original target must be an element which contains an element with class nav. So .nav should probably never be your target.
The .nav element must contain list items.
Those list items must have a <a> as a direct child.
The <a> elements selected by this are then filtered out by those whose data-target or href begin with a '#'. These href's are in turn used to select the elements contained in the element to which the ScrollSpy plugin is attached. Offsets of those selected are stored, and when a scroll occurs, a comparison of the current scroll offset is made with the stored values, updating the corresponding <a> element with the class active.
Hopefully, this summary can aid in better understanding what one might be tripping over when attempting to implement the plugin, without having to dig into the code in further detail.
Using Firefox on OSX when I cmd+click on a table cell I get an blue inner outline.
I searched for a way to disable this behavior on my web application but didn't found anything.
I tried to capture the onclick or set the CSS outline to 0px to no avail.
I also looked at MDC Mozilla CSS extension but many are undocumented.
Is there a way to remove this inner outlinein a given HTML doc?
You must set CSS property -moz-user-select to none of the container table element.
table {
-moz-user-select: none;
}
This will not only disable cell selection but will also unable you to select text inside the table.