Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
zea
Posts : 7
Join date : 2009-09-26

When Xpath not working... Empty When Xpath not working...

Fri Nov 13, 2009 6:26 am
In many cases Xpath not working at all,

for instance:
Gmail->Compose Mail -> Send button

XPath: //div[@id=':6o']/div/div/div[@id=':5j']/div[@id=':5g']/div/div/div/div[2]/b

but the next time all the above ids will be changed

So how do you defind these kind of elements if their ids are dynamically changed and do not have ids/names?

Thanks,

Zea
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

When Xpath not working... Empty Re: When Xpath not working...

Sat Nov 14, 2009 6:08 pm
Hi,

you can identify the element in selenium in many different ways like:

identifier=id
Select the element with the specified @id attribute. If no match is found, select the first element whose @name attribute is id. (This is normally the default; see below.)
id=id
Select the element with the specified @id attribute.
name=name
Select the first element with the specified @name attribute.

* username
* name=username

The name may optionally be followed by one or more element-filters, separated from the name by whitespace. If the filterType is not specified, value is assumed.

* name=flavour value=chocolate

dom=javascriptExpression
Find an element using JavaScript traversal of the HTML Document Object Model. DOM locators must begin with "document.".

* dom=document.forms['myForm'].myDropdown
* dom=document.images[56]

xpath=xpathExpression
Locate an element using an XPath expression.

* xpath=//img[@alt='The image alt text']
* xpath=//table[@id='table1']//tr[4]/td[2]

link=textPattern
Select the link (anchor) element which contains text matching the specified pattern.

* link=The link text

css=cssSelectorSyntax
Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.

* css=a[href="#id3"]
* css=span#firstChild + span

Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).

Without an explicit locator prefix, Selenium uses the following default strategies:

* dom, for locators starting with "document."
* xpath, for locators starting with "//"
* identifier, otherwise


Try to use other methods instead of xpath. check out the following thread also:

https://seleniumforum.forumotion.net/selenium-ide-discussion-f3/click-a-radio-button-that-has-a-dynamic-id-t135.htm


This will give you some hint regarding your problem. Best Of luck.

Bye
avatar
zea
Posts : 7
Join date : 2009-09-26

When Xpath not working... Empty Re: When Xpath not working...

Mon Nov 16, 2009 1:51 pm
Adviser:

Thank you so much for all the above hints. I want to try the mapped approach:

storeAttribute| path of area where radiobutton placed @ id| variableName
click| ${variableName}

The last time the xpath is:

/html/body/div[1]/div[2]/div/div[2]/div[1]/div[3]/div[1]/div/div/div[2]/div/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div[@id=':3n']/div/div/div[@id=':2f']/div[@id=':2c']/div/div/div/div[2]/b

or
div[@id=':2c']/div/div/div/div[2]/b

So I tried:
storeAttribute| //div @ id| x
but failed to save the id to x

In this case what should I put in front of @ id?

Please advise and thanks a lot!

Zea
Sponsored content

When Xpath not working... Empty Re: When Xpath not working...

Back to top
Permissions in this forum:
You cannot reply to topics in this forum