Finding font-weight value for span[2] element in Selenium IDE - selenium-ide

Is there a way to verify that element 'Adam Slodowy' is bold in Selenium IDE?
This is the fragment of site code:
...
<div class='thread-content-row.thread-content-row-1'>
<div class='thread-content-row-left'>
<div class='thread-content-row-right'>
<div class='discussion-info'>
<b>Daria Ogrodowska</b>
do
<span>super</span>
,
<span>Adam Slodowy</span>
</div>
<div class="discussion-content"> bla bl balkjbasdfsdfsdfdsfsdf sdfsdf sdf sdf </div>
</div>
</div>
I've tried to use verifyEval command:
Command: verifyEval
Target: var elem = window.document.querySelector("div.thread-content-row.thread-content-row-1 > div.thread-content-row-right > div.discussion-info span"); window.getComputedStyle(elem,null).getPropertyValue("font-weight");
Value: 700
but I have no idea how in querySelector refer to second span - querySelector("div.thread-content-row.thread-content-row-1 > div.thread-content-row-right > div.discussion-info span[2]") doesn't work.

It is really much more practical for a human person to check styles as even if it was bold it could look really bad and Selenium wouldn't be able to tell if it looked "bad" or not.
That being said, you would probably want to utilize xpath query on this one.
xpath=//span[contains(text(), 'Adam Slodowy')
or if you have more than one of those in your web page.
xpath=//div[#class='discussion-info']/span[contains(text(), 'Adam Slodowy')
the // indicates to look through the web page for an element that matches whatever follows. Which is very beneficial so that you don't have to include entire xpath which is very fragile if any of the structure changes.

Related

Typical issue: css Element not found

I have a typical problem with selenium Ide: [error] = * css Element not found.
I looked in the forum and I have seen very similar questions (eg, selenium-IDE-2.9.0 - [error] = li.xspPickerItem.xspPickerItemHover css Element not found), have tried to solve the problem with some of the suggested answers but I could not.
The details of my problem is as follows:
Log:
info] Executing: |click | css=input.select-dropdown.active | |
[error] Element css=input.select-dropdown.active not found
[info] Test case failed
HTML
(it contains several drop-down lists):
<div class="row" _ngcontent-pkb-13="">
<div class="col s2" _ngcontent-pkb-13="">
<label for="groupBy" _ngcontent-pkb-13="">Agrupado por</label>
</div> <div class="col s5" _ngcontent-pkb-13="">
<div class="select-wrapper form-control ng-untouched ng-pristine ng-valid initialized">
<span class="caret">/span>
<input class="select-dropdown" readonly="true" data-activates="select- options-32184002-bd89-baf2-43b8-3d88ae8219e5" value="Todo el territorio" type="text"></input>
<ul id="select-options-32184002-bd89-baf2-43b8-3d88ae8219e5" class="dropdown-content select-dropdown ">
<li class=""><span>Todo el territorio</span></li><li class=""><span>Instalaciones Deportivas</span></li><li class=""><span>Parroquias</span></li><li class=""><span>Polígonos Industriales</span>
(it shows a small part)
How you could select any item from the drop down ?, eg. "Parroquias"
Thanks
From the code you've posted you don't need the '.active' on the end of the locator, it should just be 'css=input.select-dropdown' However if you have multiple dropdowns this may not be the most efficient way of targetting them if they'd all have the same class. If you have control over the code you may want to add id's onto the dropdowns and use that for your target
As for getting it working, I can't get a working example on my machine as for it to appear as a dropdown you'd need your css, as you've coded it to just be a list but the css formats it as a dropdown, rather than using the 'select' tag. Normally you'd use the 'Select' command in Selenium, targetted at the dropdown, rather than a click command but I'm not sure if it would work with the way this page is coded as I've not come accross it before (my instinct would be no) so it probably would be the click on the dropdown as you're trying, then a click on the specific list item.

Need help to click Watir Web driver button

I have the HTML as
<li>
<div data-track="discovered_spots" data-filter="discovered_spots" class="button filter-button">
<span class="icon-compass"></span>
Discoveries (2)
</div>
</li>
I am trying to click the button link
#browser.div(:class =>'button filter-button').span(:text => ' Discoveries (2) ').click
Just not working or producing any errors.
I have also tried using the xpath
##browser.div(:xapth => "//div[#data-track='discovered_spots']").click
##browser.div(:text => "Discoveries").click
but that produce errors.
I have also viewed and tried the code present in other questions chains but none worked any help will be very useful.
Try:
#browser.div(:text, /Discoveries/).click
Regex for the attribute should hit the text. Not specifying \d anchor will cast a wider net in case that value of 2 fluctuates by only looking for the match of Discoveries in text and ignoring the number and parentheses.

Replacing <a>-tag linktext with different text

I try to map the following html (it´s a small fce)..
<div>
<div data-hero="1">
<h1>
<!-- Headline -->
</h1>
<p>
<!-- Small Text -->
</p>
<p>
<a>
<span><!-- Button Text --></span>
</a>
</p>
</div>
</div>
Mapping is ok... But when i map the <span> i get a No content found div[1] div[1] p[2] a[1] span[1] error. The <a>-Tag is mapped outter so it should work..
What I try to achieve: Set a Text that is displayed in the <a>-tag, instead of the link target itself.
It´s a TYPO3 4.7 using the latest TemplaVoilà.
Why is that? Thanks in advance!
Edit
#biesior suggested this is not possible - so no i wrap a <span> into the <a>-tag via Typoscript.
Is there a chance to display a certain fields content in this <span> - speak: replacing the linktext, so that i can have a Click here for more ... instead of pageXY?
Btw: I use a linkfield and not the Rich-Text-Editor for setting the link.
You can not map any element nested in previously mapped element.
The fastest solution is mapping the A tag, and wrapping inserted text with <span>|</span> with TypoScript.

Traverse to get to innerHTML

Using Selenium IDE, I need to verify the text "Schedule Entry Worksheet for ZBW - Boston Center" is present. I'd like to use AssertTextPresent to do this. I'm using Firebug to identify the path to the element.
Here's what I've done so far in IDE:
Command: assertTextPresent
Target: xpath=//html/body/div[7]/div[2]/div/div/span
Value: Schedule Entry Worksheet for ZBW - Boston Center
However, I'm getting "[error] false" in the log section. Does anyone know what I'm doing incorrectly?
Below is a snippet HTML for the page:
<div id="worksheet_div" style="display: inline;">
<div class="fg1" style="width: 2010px;">
<div class="fgt">
<span style="padding-right: 10px; background-color: #E3EFFF;">Schedule Entry Worksheet for ZBW - Boston Center</span>
</div>
does it matter where the text is or just that it is somewhere? if it is the latter you could do something as simple as
css=span
if position on the page matter then need to add more structure to it
css=.fgt span
or similar.
it is also useful to use the firefinder plugin for firefox to debug xpath and css

how can i check full DOM path easily

im making some script with python PAMIE module.
inside my script im using internet explorer object and to handle this object
im using DOM path but it not easy to check Full dom element path .
for example , how can i search full dom path such like format?
divChild.nextSibling.nextSibling.nextSibling.nextSibling.childNodes[0].nextSibling.nextSibling.nextSibling.nextSibling.childNodes[0].childNodes[0].childNodes[0].childNodes[0]
it not easy to check manually
if anyone help me much apprecaite!
could you identify the node by object id ?
document.getElementById("elementId")
try to use this : https://github.com/asatour/jquery-domPath.
To get DOM Path of HTML jquery element
<body>
<div class="module" id="products-block">
<div class="description">
<h1 class="section-title">
product general description
</h1>
<ul class="products">
<li>Cameras</li>
<li>TV</li>
<li>Computers</li>
</ul>
</div>
</div>
</body>
JavaScript :
var products_domPath = $(".products").domPath();
Output:
["div#products-block.module > div.description > ul.products"]