test variable title with ID - selenium ide - css

using selenium IDE i testing my site
in some pages i have a link with variable ID
ex : ( http://yourorder.com/135046 )
every time user click on this link site take him to process page number (135046)
so this number always changing ( variable )
so i can't use
<tr>
<td>click</td>
<td>link=yourorder.com/135046</td>
</tr>
what i can do ?
help please

you locate the element by this xpath:
"//td[contains(text(), 'link=yourorder.com')]"

There is various other options in for selection of target in SELENIUM IDE.
Sequence of selecting target value is following:
ID
NAME
LINK
DOM
CSS
XPATH
Structure of XPATH is //html tag[#property='value']
So you can try with these.

click > //html/body/div[6]/div[3]/div/div/div/table/tbody/tr/td[2]/a
thanks everyone

Related

Find next element in Katalon

How do I get the element next to currently selected element?
So my scenario is I open a page and click some button to load a table. When I click on the header of any column in the table it sorts and adds an image next to it. I have a locator for the header link. Problem is as it's old code it does not have id and that header link is in a td tag without any id or class. All it contains is a column name with a link. I want to make sure when I click that link image with sorting symbol appears next to it.
<td>
<a>Column Header</a>
</td>
Click on the column header and it changes to :
<td>
<a>Column Header</a>
<img src="sorting icon url" />
</td>
This can be done through something called XPath axes , refer this link
http://learn-automation.com/how-to-write-dynamic-xpath-in-selenium/
the following methodologies work in katalon as well , you will have to make an object and give the xpath of that object.
for your query xpath could be ://div[#class='xyz']/following-sibling::*
Let us asume that the button is uniquely identified by css selector 'td a'. Then your script could be something like
TestObject button = new TestObject().addProperty('css', ConditionType.EQUALS, 'td a')
WebUI.click(button)
TestObject button2 = new TestObject().addProperty('css', ConditionType.EQUALS, 'td a img')
WebUI.waitForElementHasAttribute(button2, 'src', 30)
It will return true if the img with any source is present. Will wait 30 seconds before giving an error, but you can change it as you wish.

Simple HTML Dom get href that begins with

I am using Simple HTML Dom to extract information from a remote source. I would like to get all href links that contain a particular piece of text (not all on a page). I have tried
->find('a[href*="/place"]')
and
->find('a[href="/place"*]')
and
->find('a[href="/place*"]')
but this returns empty results.
The href I am trying to get must begin with the text "/place".
Any suggestions?
Thanks
Match elements that have the specified attribute and it starts with a certain value, use [attribute^=value].
->find('a[href^="/place"]')
Ref: http://simplehtmldom.sourceforge.net/manual.htm#frag_find_attr
I do not now this app, however did you try using the asterisk like so ?
>find('a[href="/place*"]')

selenium dynamic value - for textbox

I am in the middle of building a test case, where i came across this problem. In my web page there exists a search text box. I have recorded the web page using selenium ide.
type | id=search_input_char_name_136 | myproduct // textbox for search
click | css=button.oe_button | - // search icon click
I got the above code by recording, here in "type" action an id value is show for textbox, when i use the same value while testing, id not found error occurs. so i have recorded the action again and i found id is dynamic. for each time the id keeps on changing.
i have googled it and found xpath will be solution for this. i am very new to selenium and xpath. i couldn't figure out the solution. so help to slove this.. provide me the xpath syntax to type=id of search-textbox.
In the selenium IDE itself, after the recording is finished, try to click the drop down named Target in the IDe window for this textbox. There, in that drop down, you can get various locators like xpath, name, css, dom etc. Observe, which one is static for all the recordings and use that locator. Hope it helps. Let me know if you are still struck with this issue.

How to get the CSS attributes from a control located by XPath using Selenium IDE

In my Selenium IDE script, I need to check for an error state.
This error state is visually indicated on the page by a select control's background turning to a light red color.
The xpath for the select control is:
.//*[#id='tab-PersonnelDetailPeriod1-div']/div[3]/table/tbody/tr[2]/td[2]/div/select
The HTML for that select control is:
select style="background-color:#FFD5D5" tabindex="0" name="newBudgetLineItems[0].costElement"
I would like to store the background-color in a variable and then use the gotoIf command from the Flow Control plugin to execute additional steps if the variable holding the color is FFD5D5.
Is this possible within Selenium IDE?
Thanks in advance to anyone who assists.
EDIT: another approach could be locating any select element which has a background-color style, as all other selects on the page do not have any background color specified.
Besides the xpath locator //select[#style='background-color:#FFD5D5'],
you can try verifyAttribute
or maybe JavaScript window.getComputedStyle(*element*,null).getPropertyValue('backgroundColor');.

How to use seleniumRC in Junit framework on dynamically changing elementids

I am trying to automate a work flow process .In this,I need to click on a link positioned in any of the rows of table.Thing is all links available in all rows have same element ID and in the source code I have a java script like " ("Element ID" # Onclick..java script****:).....SO here after clicking it is connecting one form to another form by inputting some value in java script code and also one value in java script dynamically changes.How do I click on that link now?Is there any solution using xpath or so...to exactly click on that link based on CSS classID or so...Please help me out..Main problem is...all links in rows have same element ID and dynamically changing java script .
I am trying to use selenium.focus() and selenium.clickAndwait().But these are helpless.as it is not able to identify link ID only.
The best way to do this would be with xpath.
Something like //*[#onclick='javascript'] will work but this can make the tests extremely flaky because if the inline javascript changes or if its removed in preference of addEventListener to the element.
something like //*[#class='cssClass'] will work. I think that you will need to speak to the developers and ask them to help make it more testable.

Resources