I'm trying to get the value of an attribute ('div' element, 'rowid' attribute) using "Get Element Attribute" but am getting the below error. I'm trying to get the value for this entry, rowid="3f0df873-ff38-4637-a69e-831040b9d0ce".
I've verified my xpath using XPath Checker in Firefox and also in Firebug. I've also tried different xpath forms which also verify using XPath Checker and Firebug but to no avail.
In looking at the Selenium2Libary documentation for "Get Element Attribute" is seems that its looking for a specific form ("element_id@class") that I can't seem to achieve due to having to go back up the tree for the div element.
I'm new to XPath so perhaps there is a way to get this in the form that the S2L keyword is expecting or maybe there is a better locator strategy.
Any insights into "Get Element Attribute" or perhaps a better approach would be greatly appreciated.
My XPath:
//*[text()='Advanced Operator Tasks']/ancestor::div[1]/@rowid
My HTML:
<div parentid="" rowindex="12" rowid="3f0df873-ff38-4637-a69e-831040b9d0ce" visualindex="12" role="row" class="gridxRow gridxRowSelected" data-rowheight="21" aria-selected="true">
<table cellspacing="0" cellpadding="0" border="0" role="presentation" class="gridxRowTable">
<tbody>
<tr>
<td style="width:250px;min-width:250px;max-width:250px;" class="gridxCell" colid="name" aria-describedby="rolesTable_grid-name" tabindex="-1" role="gridcell" aria-readonly="true">Advanced
Operator Tasks</td>
<td style="width:431px;min-width:431px;max-width:431px;" class="gridxCell" colid="description" aria-describedby="rolesTable_grid-description" tabindex="-1" role="gridcell" aria-readonly="true">Advanced
Operator Tasks</td>
</tr>
</tbody>
</table>
</div>
ERROR:
------------------------------------------------------------------------------
Create User Template :: describe test here | FAIL |
InvalidSelectorException: Message: The given selector //*[text()='Advanced Opera
tor Tasks']/ancestor::div[1]/@rowid is either invalid or does not result in a We
bElement. The following error occurred:
InvalidSelectorError: The result of the xpath expression "//*[text()='Advanced O
perator Tasks']/ancestor::div[1]/@rowid" is: [object Attr]. It should be an elem
ent.
Stacktrace:
at FirefoxDriver.annotateInvalidSelectorError_ (file:///c:/users/ibm_ad~1/ap
pdata/local/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriver@googleco
de.com/components/driver-component.js:9615:1)
at FirefoxDriver.prototype.findElementsInternal_ (file:///c:/users/ibm_ad~1/
appdata/local/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriver@google
code.com/components/driver-component.js:9673:9)
at FirefoxDriver.prototype.findElements (file:///c:/users/ibm_ad~1/appdata/l
ocal/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/
components/driver-component.js:9677:3)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/ibm_ad~1/ap
pdata/local/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriver@googleco
de.com/components/command-processor.js:11635:16)
at DelayedCommand.prototype.executeInternal_ (file:///c:/users/ibm_ad~1/appd
ata/local/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriver@googlecode
.com/components/command-processor.js:11640:7)
at DelayedCommand.prototype.execute/< (file:///c:/users/ibm_ad~1/appdata/loc
al/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/co
mponents/command-processor.js:11582:5)
------------------------------------------------------------------------------
HMC User Mgmt User Template :: User Management Scenario 01: Verifi... | FAIL |
3 critical tests, 2 passed, 1 failed
3 tests total, 2 passed, 1 failed
==============================================================================
From the Selenium2Library docs:
http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Get%20Element%20Attribute
Get Element Attribute attribute_locator
Return value of element attribute.
attribute_locator consists of element locator followed by an @ sign and attribute name, for example "element_id@class".
Ugh
Your selector is not correct, to be precise it is not valid xpath. In you case xpath to select correct element would be:
//*[text()='Advanced Operator Tasks']/ancestor::div[1]
Then to get the row id attribute with Get Element Attribute [1] keyword, you must define the argument in this way:
xpath=//*[text()='Advanced Operator Tasks']/ancestor::div[1]@rowid
-Tatu
Send from my mobile
[1] http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Get%20Element%20Attribute
Hi Tatu, Thank you for the reply. I've tried many different xpath forms and had actually guessed at this form but both XPath Checker and Firebug indicated a syntax error so never tried it. xpath=//*[text()='Advanced Operator Tasks']/ancestor::div[1]@rowid Seeing your reply I thought maybe the checkers are wrong so I reran with your suggestion but am getting the below error. When I use "XPath Checker" with this form it returns '3f0df873-ff38-4637-a69e-831040b9d0ce'. xpath=//*[text()='Advanced Operator Tasks']/ancestor::div[1]/@rowid
Any other suggestions are appreciated.
------------------------------------------------------------------------------
Create User Template :: describe test here | FAIL |
InvalidSelectorException: Message: The given selector //*[text()='Advanced Opera
tor Tasks']/ancestor::div[1]@rowid is either invalid or does not result in a Web
Element. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression //*[
text()='Advanced Operator Tasks']/ancestor::div[1]@rowid because of the followin
g error:
SyntaxError: The expression is not a legal expression.
Stacktrace:
at FirefoxDriver.annotateInvalidSelectorError_ (file:///c:/users/ibm_ad~1/ap
pdata/local/temp/tmp4yghz8/webdriver-py-profilecopy/extensions/fxdriver@googleco
de.com/components/driver-component.js:9615:1)
at FirefoxDriver.prototype.findElementsInternal_ (file:///c:/users/ibm_ad~1/
appdata/local/temp/tmp4yghz8/webdriver-py-profilecopy/extensions/fxdriver@google
code.com/components/driver-component.js:9673:9)
at FirefoxDriver.prototype.findElements (file:///c:/users/ibm_ad~1/appdata/l
ocal/temp/tmp4yghz8/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/
components/driver-component.js:9677:3)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/ibm_ad~1/ap
pdata/local/temp/tmp4yghz8/webdriver-py-profilecopy/extensions/fxdriver@googleco
de.com/components/command-processor.js:11635:16)
at DelayedCommand.prototype.executeInternal_ (file:///c:/users/ibm_ad~1/appd
ata/local/temp/tmp4yghz8/webdriver-py-profilecopy/extensions/fxdriver@googlecode
.com/components/command-processor.js:11640:7)
at DelayedCommand.prototype.execute/< (file:///c:/users/ibm_ad~1/appdata/loc
al/temp/tmp4yghz8/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/co
mponents/command-processor.js:11582:5)
------------------------------------------------------------------------------
HMC User Mgmt User Template :: HMC User Mgmt User Template: Verifi... | FAIL |
3 critical tests, 2 passed, 1 failed
3 tests total, 2 passed, 1 failed
==============================================================================appdata/l ocal/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriv...@googlecode.com/ components/driver-component.js:9677:3) at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/ibm_ad~1/ap pdata/local/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriver@googleco
de.com/components/command-processor.js:11635:16) at DelayedCommand.prototype.executeInternal_ (file:///c:/users/ibm_ad~1/appd ata/local/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriver@googlecode .com/components/command-processor.js:11640:7) at DelayedCommand.prototype.execute/< (file:///c:/users/ibm_ad~1/
appdata/loc al/temp/tmpfqexp1/webdriver-py-profilecopy/extensions/fxdriv...@googlecode.com/co mponents/command-processor.js:11582:5) ------------------------------------------------------------------------------ HMC User Mgmt User Template :: User Management Scenario 01: Verifi... | FAIL | 3 critical tests, 2 passed, 1 failed 3 tests total, 2 passed, 1 failed ============================================================================== From the Selenium2Library docs:
Markus
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
Markus
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.