hi how to use Get Element Attribute in Robot framework? in instruction I have
Return value of element attribute.
attribute_locator consists of element locator followed by an # sign and attribute name, for example element_id#class.
I have this xpath=${check_radio_xpath}#class is this right way?
where ${check_radio_xpath} = md-radio-11
I get this error:
${ischecked} = Selenium2Library . Get Element Attribute xpath=${check_radio_xpath}#class
Documentation:
Return value of element attribute.
TRACE Arguments: [ 'xpath=md-radio-11#class' ]
DEBUG Finished Request
FAIL ValueError: Element 'xpath=md-radio-11' not found.
I think you're pretty close. Please try to format your question better, I took a quick shot because your question is difficult to read. The result will be more and better help from the community
${RADIO_XPATH} //*[#id="${check_radio_xpath}"]
${CLASS}= Selenium2Library.Get Element Attribute ${check_radio_xpath}#class
sample for this <div><label for="foo"></label></div>
${for_value}= Get Element Attribute xpath=//div/label for
Log To Console ${for_value}
console result is:
foo
This snippet works for me :
Get Line Numbers And Verify
${line_number1}= Get Element Attribute //*[#id="file-keywords-txt-L1"] data-line-number
Log To Console ${line_number1}
${line_number2}= Get Element Attribute //*[#id="file-keywords-txt-L2"] data-line-number
Log To Console ${line_number2}
Verify in order of ${line_number1} and ${line_number2} is true
What was important is that the spaces/tabs between the keywords are correct, otherwise it does not get recognised as a so called keyword.
Thanks a lot, i wanted to check meta noindex content in page source.
i used this.
${content} Get Element Attribute xpath=//meta[#name="robots"]#content
should be equal as strings ${content} noindex,follow
You can use both XPath and CSS selector if you have selenium library
${title}= Get Element Attribute ${xpath} attribute=title
Related
Does anybody work with Tosca (module) and has the same error in testcase: Container 'x' was not found?
The attr is already adapted: XPath-> correct; Visible=true; ClassName -> correct.
What should be done, that the tosca can find this container?
thank you
it could be a maintenance error, i.e. certain container does not exist anymore or
you should re-scan new one. I'm using e.g. selector data-tosca instead of xpath
I'm a tester, and I have this HTML code.
<div id="columns">
<div class="column ce-editable c1">
</div>
</div>
I'm using Cypress. I want to examine if there is 'c1' class name found in the div element. If I try:
cy.xpath ('//div[#id="columns"]//div')
.should('have.class', 'c1')
I have this error:
CypressError: Timed out retrying: You attempted to make a chai-jQuery assertion on an object that is neither a DOM object or a jQuery object.
The chai-jQuery assertion you used was:
> class
The invalid subject you asserted on was:
> [<div.column.ce-editable.c1>]
To use chai-jQuery assertions your subject must be valid.
This can sometimes happen if a previous assertion changed the subject.
May I give you a whole other direction. It goes far, far away from using Xpaths :). What you can do to archive what you want is the following:
cy.get('#columns')
.find('div')
.should('have.class','c1')
This results in a few positive things:
1. It's easier to read what is happening
2. Debugging is easier, you'll see that Cypress tries to verify c1 in three steps. First find some ID with 'columns', than find a div below that and finish with asserting that the last searched div has a class called 'c1'.
3. The results show more neath since should() is actual an assertion instead of an action.
In Polymer 1.0, I am trying to data bind a string variable {{str}} to an <iron-meta> element (tag in parent element) as follows.
This fails:
<iron-meta id="meta" key="info" value="{{str}}"></iron-meta>
The above code breaks. But the following code works (without the binding).
This works:
<iron-meta id="meta" key="info" value="foo/bar"></iron-meta>
The difference is the variable version {{str}} fails and the constant version "foo/bar" works.
Does anyone have a clue what is what is breaking the binding and how to fix it?
Edits in response to comment questions:
How does it fail? This fails silently. The values I have printed out simply do not update when I press the Login and Register buttons.
Here is a link to the code in a Github repository. See lines
You need to use an attribute binding and not a property binding
<input type="text" value$="{{str}}" />
I have the following code, where I need to get the value:
<a href="/checkout/cart.jsf">
Items:
<span class="numberofitems">1</span>
</a>
However, when I attempt to point at it using css=span [class='numberofitems'], I get the message "The element has no value; is it really a form field?" The element does have a value which I can see in Firebug, but I can't figure out how to properly store this value.
Here we go.. every WebElements given below will give better outcome to get the value '1'.
By.xpath("//a[#href='/checkout/cart.jsf']/span")
By.xpath("//a[text()='Items: ']/span"))
By.xpath("//span[#class='numberofitems']")
If they are not working,
Check whether the Elements are HIDDEN with help of Firebug.
Check whether the classname, 'numberofitems' is repeated.
I'm trying to test for the presence of a string somewhere in a long webpage. Using PHPUnit's assertRegExp if the string is not found it prints out the entire page and then finishes with matches PCRE pattern "/xxxxxx/". According to the documentation I should be able to specify a message a third that will be printed out if the test fails. That message is printed, followed by the full page source. What I'd like to do is just print the message. Using Selenium in my previous apps I used assertTextPresent and it would just print out confirmation that the text was/was not found, without filling my screen.
I have tried wrapping the assertRegExp in a try-catch but it didn't change anything.
You could try assertContains() instead of assertRegexp().
PHPUnit is responsible for printing out the failed text, and this differs from one assert method to another. It just might work.
If it does not, open an issue at PHPUnit's issue tracker about PHPUnit printing too much out.
I am using the getBodyText() method to get all page content and than I use assertTextPresent() to check the presence of pattern.
$this->assertTextPresent($this->getBodyText(), 'text to find');
The solution has been positivly tested with latest phpunit 4.7.
I use assertTrue(stripos($haystack, $needle) !== false, 'Failed assertion message');