I would like to add double click ads tags to an element using :
googletag.defineSlot(adUnitPath, size, opt_div) Constructs an ad slot
with a given ad unit path and size and associates it with the ID of a
div element on the page that will contain the ad.
like this :
googletag.defineSlot('myslot', [728, 90], 'ad-container')
the ad-container div is in a Polymer webcomponent and the application is set with shadow dom enable. The div is not found by googletag api. The publisher console output :
Slot 'myslot' does not have a container div with id: 'ad-container'.
if app is switch to shady dom, it works.
Is there a way to get googletag with shadow dom ?
Related
I've been attempting to web scape some detail from the following website, but I'm unable to figure out how to access the class, id, and class type for the following object below.
https://mor.nlm.nih.gov/RxClass/search?query=H%7CATC1-4&searchBy=class&sourceIds=&drugSources=atc1-4%7Catc%2Cepc%7Cfdaspl%2Cmeshpa%7Cmesh%2Cdisease%7Cndfrt%2Cchem%7Cfdaspl%2Cmoa%7Cfdaspl%2Cpe%7Cfdaspl%2Cpk%7Cndfrt%2Cva%7Cndfrt%2Cdispos%7Csnomedct%2Cstruct%7Csnomedct
On the following website with the search condition you'll see in the center of the screen it
class: SYSTEMIC HORMONAL PREPARATIONS, EXCL. SEX HORMONES AND INSULINS / id: H / class type: ATC1-4 / show context
I'd like to make the assumption that the above is in bold is a CSS_Selector, but I can't seem to locate it.
Any guidance on how to locate the class, element, or css_selector would be much appreciated.
You can use the developer console in Firefox or any Chromium-based browser: open the contextmenu on the element you want and select Inspect. Then the developer console should open. The current element should be focused in the DOM tree. There you should have the option Copy > CSS selector. And you're done. In your current case the path is something like this:
html body div.container-fluid div.col-sm-9.col-sm-offset-3.col-md-9.col-md-offset-3.main div#tabContent.tab-content div#drugMemberPane.tab-pane.active div#drugMemberPage.table-responsive div.propText strong
I have a div with a property panelname that changes depending on which view in a multi step process I am in (every panel has a Next-button).
It takes a few seconds after each click on Next for the next panel to load and render. This div has the same ID on every step instead panelname changes for each view.
I can read the value for panelname using Get Element Attribute but how do I use this in one of the Wait until page/for element, or similar, keywords?
The following should work, assuming you know each panel's name:
Wait Until Page Contains Element //div[#id='sameId' and #panelname='name2']
This the example HTML for the keyword above:
<div id="sameId" panelname="name2"></div>
I am using Python 2.7, Webdriver and Chrome. Manually, I can mouse swipe across text containing a hyperlink on a web page and copy it to the clipboard. How do I do this automatically? I have no issue finding the element containing the hyperlink. I am not trying to find the hyperlink. I am trying to paste it into a web page text box which does not process https://www.python.org/ ">Link within an "a" tag but processes it correctly when pasted from elsewhere i.e. "Link" with embedded href.
Even after OP clarifications, it's still hard to understand the exact issue, so I'll try to cover all possible options :)
Suppose we have an anchor element, like Link
We can find this element in such ways
element = driver.find_element_by_xpath('//a[text()="Link"]')
element = driver.find_element_by_xpath('//a[#href=" python.org "]')
depending on what information we currently know about the element and what exactly we want to scrap.
Also, we can use index of anchor element element = driver.find_elements_by_tag_name('a')[0]
1) To get value of href attribute:
value = element.get_attribute('href')
Output: https://python.org
2) To get value of text node:
value = element.text
Output: "Link"
3) To get complete HTML code of element:
value = element.get_attribute('outerHTML')
Output: Link
I am using the google-map element and I read about the .resize() trick to fix the size of a google-map element.
However I could not get it to work. Moreless, it doesn't make sense to me.
In my application:
only the first page which displays maps renders properly. Another page which render a map will not render properly.
if the first page rendered doesn't contain a map, if I go to another page with a map, the map renders properly.
That is why I do not understand how this can be related to the core-animated pages.
Live demo:
http://nicolasrannou.github.io/webapp-core/components/webapp-core/demo.html#welcome/home
All the "Contact" pages contain maps.
The maps are created after pulling data from a google doc, using a template:
<template repeat="{{row, rowIndex in rows}}">
<!-- location -->
<template if="{{ row.gsx$type.$t === 'location'}}">
<google-map latitude="{{+ row.gsx$latitude.$t}}" longitude="{{+ row.gsx$longitude.$t}}" showCenterMarker zoom="15">
</google-map>
</template>
</template>
Those "google-map" element are pretty far in the shadow dom and encapsulated in templates.
I tried to access then in the core-animated-prepare event without success:
transitionPrepare : function(){
window.console.log(document.querySelectorAll('google-map'));
}
Is there a good way to access an element inside a template, inside a shadow dom?
Thanks
On accessing inside a shadow dom, here is one citation from the docs:
...If the element is in another shadow tree deep within another element, you can't traverse into it easily. You can use .shadowRoot if you really need to poke around:
element.shadowRoot.querySelector('x-other-element')
.shadowRoot.querySelector('#something');
On maps that do not resize properly, I'll first look at the timing: .resize() should be done AFTER the animation is completed.
In codedUI I am unable to traverse by GetChildren() method in an html page with HTML5 tags.
My Html structure is like this.
HTML
|-BODY
|-DIV id="pagetop"
|- HEADER class="headerclass"
|- NAV class="navclass"
|- SECTION class="sectionclass"
|- FOOTER class="footerclass"
|- DIV id="lastdiv"
Issue: On doing GetChildren() on "pagetop" div control, only 1 result is returned having "lastdiv" div control in it.
It should return 5 controls instead.
I am able to capture the UIMap for SECTION(or other HTML5 tags) and able to traverse backward by GetParent() method, but the other way is not working.
SECTION.GetParent() = DIV id="pagetop" [Works as expected]
SECTION.GetParent().GetChildren() = Only 1 result [This is wrong, should be 5]
Is there an issue with traversing HTML5 tags in codedui?
Try looking at the child controls of the one control that is found. I am not aware of anything that says the HTML structure you show MUST be represented with exactly the same number of levels. Phrasing that differently, the UI Controls might have extra levels than the minimum that appear to be necessary for the HTML structure.
To understand how the HTML is represented you could use the Coded UI cross-hairs tool. Start with one of the five sections (or a child of theirs) and then use the four navigation arrows to move up through the hierarchy to see what items Coded UI can see at each level.
Another approach might be to use recursive code that calls GetChildren() to descend the hierarchy and show exactly what is present at each level. You might use code based on the recursive routine in my answer to this question Recursively locating a UIElement with InnerText in C# but using a small maxDepth and adding some Console.Writeline() or other print statements to display the controls found.
I have filed one bug in VS2013 feedback forum for this issue.
It can be tracked here: https://connect.microsoft.com/VisualStudio/feedback/details/898599/
Based on suggestions from AdrianHHH, I am currently doing this to get all the children of a control. This returns all controls including HTML5 controls as HtmlCustom.
private List<UITestControl> GetAllChildren(UITestControl uiTestControl)
{
var child = new HtmlControl(uiTestControl);
child.SearchProperties.Add("InnerText", "", PropertyExpressionOperator.Contains);
var items = child.FindMatchingControls().ToList();
var trueChildren = items.Where(i => i.GetParent().Equals(uiTestControl)).ToList();
return trueChildren;
}