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
maggiexg
Posts : 3
Join date : 2009-09-23

How to create/recognize object element not using recording? Empty How to create/recognize object element not using recording?

Wed Sep 23, 2009 4:17 am
Hi,

I have the following questions:

1. How to create an object element not using recording method?
for example, by scripting
clickandwait
Go (image link)

Will Selenium find the Go link on the page? Can we use the labels on the screen to run as many actions as we like this way?

2. How Selenium recognize a UI element?

Thanks,

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

How to create/recognize object element not using recording? Empty Re: How to create/recognize object element not using recording?

Wed Sep 23, 2009 10:58 am
hi,

If you want to create script manually not using record and play feature of selenium, it is simple.

For this you have to start you application and IDE. Suppose you have login page and you want to create object for all object present on that screen. The following are steps:

1. go to first element username field, right click with mouse. It will show some command of selenium in mouse popup. select verifyElementPresent.
2. Moe one step is recorded in selenium ide. go and have a look.
3. Now modify that command, do type instead of verifyElement.
4. leave the Target field, it is your object locator.
5. Type username in value option of IDE.

By this way you can get object of any element and modify according to your need. Selenium will not find "GO" you have to provide actual dom locator or xpath.

Selenium will recognize the element in following ways:

Element Locators tell Selenium which HTML element a command refers to.
The format of a locator is:

locatorType=argument
We support the following strategies for locating elements:



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


Hope this will help you. Best of luck.

Bye
avatar
maggiexg
Posts : 3
Join date : 2009-09-23

How to create/recognize object element not using recording? Empty Re: How to create/recognize object element not using recording?

Wed Sep 23, 2009 11:38 am
Hi Adviser,

Thanks for the detailed explainations and I found the context menu by following your steps. It is so helpful!

MX
avatar
kmahata@gmail.com
Active particpant
Active particpant
Posts : 10
Join date : 2009-11-06

How to create/recognize object element not using recording? Empty Re: How to create/recognize object element not using recording?

Sat Nov 07, 2009 2:48 pm
Hi Maggie

U may use Firebug addon in FF. Through this u can know the locators. Capture them and type the command u want to perform on them
Sponsored content

How to create/recognize object element not using recording? Empty Re: How to create/recognize object element not using recording?

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