In a web page I am trying to test, I need to click on the element defined by the following:
<span id="mx45" class="text powerwhite goto " title="Go To ALT+G " style="display: block; cursor: pointer;" accesskey="G" mxevent="click" targetid="mx45" ev="goto" tabindex="0" ctype="label" align="middle" clicked="true">
I can't use the id because when the server restarts, the id changes. I tried getting the XPATH from Firebug (as I have done for lots of other elements) but that does not get found. All suggestions gratefully received.
EDIT
Thanks to the answers I am now able to select the element, but this has presented a new problem. The element is a link which pops up a menu, but if I try to get Selenium to click on the link, it just flashes (like Selenium is finding it, but can't click on it). If I click the link, my test continues, but I am struggling a bit here to make Selenium actually click the element.
I don't know about the structure of your html,
but given, the title is unique, you could do somthing like this:
driver.find_element_by_xpath("//span[#title='Go To ALT+G ']").click()
you could also go for "tabindex" or "class", if your html-structure allows it.
someParentElement.find_element_by_xpath("//span[#tabindex='0']").click()
someParentElement.find_element_by_xpath("//span[#class='text powerwhite goto ']").click()
Which would for example be the case if you can find a parent-element below which these attributes are unique
Assuming the attributes I am referencing are static I would use CSS selectors referencing attributes like drkthng used
$$(span.text[title='Go To ALT+G ']").
You can also use a static neighboring element as an achor and navigate from it.
Related
I created classic report with check boxes using apex_item.checkbox .I want to know how to allow to check only checkbox.That is if i click more than checkbox alert message should display.Please help me out
Thanks in advance.
If you want to do this via dynamic actions then you will want do a dynamic action on event Change, Selection Type jQuery Selector and the jQuery Selector being input[name = "something"]
This something you can figure out by running the page as is, and if you click F12 on your keyboard, the console will open. Then select the element that is your checkbox and find its name and this should be your "something". Play around with this to make it work(set the DA to run an alert or something to see when its triggered).
Then perhaps have a page item that is filled when this DA runs, and then if the page item is already filled and the DA runs, throw up an error saying you cant do this.
Or if you want to clear the previously checked box, you could save the name of currently checked box in the page item. And have the DA do a javascript function that clears the value in the field in the page item.
Basically have the DA get the name of the checked box from the item where you store it, and do some dynamic javascript. When I needed to do something similair I created a var in javascript that was formed like $s(" + checked_box + ", ""); assembling this with concat. And then do an eval(this_concacted_instruction).
I hope my ramblings guide you to a solution. I remember the first time I was working with this stuff I took a week to get one page sorted(although it was a bit more difficult than your problem), but it felt sooo good when I got it done. So keep on trying.
GLHF
I have used click process in selenium with python more and more correctly. But, I don't know why it don't work correctly now in my code:
number=driver.find_element_by_xpath("""//*[#id="ui-id-4"]""")
number.click()
The HTML code of that is similar to:
<div id="ui-id-4" tabindex="-1" role="option" class="ui-menu-item-wrapper ui-state-active">200</div>
In fact, I previously succeed to click on "resultsPerPage-button" and now I want to select 200 per page button between 20,50,100 and 200. I used selenium in my code.
What should I do?
I used id instead XPath and it worked well. Also, use of delay was essential for this code.
import time
numberl=driver.find_element_by_id("ui-id-4")
numberl.click()
time.sleep(8)
I use the following page as example:
http://isbndb.com/book/the_new_public_health_second_edition
You can see the box "Loading Prices" when you first load the page, and it will change afterwards to show relevant information on the same box as below:
I am trying to building some price comparison engine using django, and I think I need to inform user that the page is now loading, rather than letting user to wait in front of a blank screen.
Can anyone tell me know to do it?
In your HTML
<div id="lazyLoad">
<img src="\path\to\loading.gif">
</div>
On successful ajax call replace the innerHTML of #lazyLoad with the formatted result.
I have some item content that is working just fine... but shows up as a broken link in the Broken Links Report. The link in question is in a Rich Text field:
<img style="WIDTH: 700px; HEIGHT: 1029px" class="imageBG" alt="All Alaska Map" src="~/media/Images/NorthToAlaska/maps/allAlaskaRouteFLNew.jpg?w=700&h=1029&as=1" />
If I use the built-in editor and insert an image, it generates a link like this:
<img width="700" height="1029" alt="All Alaska Route Map" src="~/media/F82D13579F3A4D0E88C4436D84A562F8.jpg?w=700&h=1029&as=1" />
I should note, that even using the "Insert Media Item" button, it shows up as a broken link. :(
In general, I'd much rather have the image path referenced than an item GUID that is impossible to identify if I'm just looking at it.
1) Why does that first link show up as broken, even though it works fine on the site?
2) Is there any way to get the editor to insert media item links with paths instead of GUIDs?
3) Alternately, is there a way to modify the way broken links are detected or reported?
Hej Bryan
1: Did you try to rebuild the Link Database?
To rebuild the Link Database you just have to open the Control Panel and go to the Database point. There will be an option where you can rebuild the Link Database.
2: I'm asuming you are meaning the rich text editor. It's on purpose that it inserts IDs instead of paths. If Sitecore would use paths it couldn't detect if you move the target item elsewhere in the tree. To get friendly URLs out of that you need to use the right controls of Sitecore. In XSL for example sc:fld won't render friendly URLs use sc:field instead.
3: In what way do you want to modify it? A custom report?
I have a menu created in ASP.NET master page. I have implemented CSS properties to menu items like hover and link, but I am not able to implement the properties for changing the color of the selected item in the menu.
Do I need to write any JavaScript or jQuery code for identifying the selected item in the menu? Please help me, as I am new to this type of menu items.
if you mean that you want to change the color of a menu item persistently (like, say, the current page tab of a navigation menu is always some particular color), you can do this in ASP by adding a class or id attribute to the menu item when it is clicked. I'm not an ASP kind of guy, but in PHP, you can do it by doing something like:
<li>page #n</li>
and then when the page in question is loaded, the navigation code should say something like:
if $_GET[page]=n then echo " class=\"selected\"" into the anchor tag.
know what i mean? I didn't type out the code for the above if statement because I'm pretty sure ASP is a little different from PHP, and you would have to translate anyway, but I hope this is helpful.
Andy
Edit: ## Here's my ASP guesswork after a brief encounter with google: ##
<li
<%
if Request.QueryString("page")==n Then
Response.Write(" class=\"selected\"")
%>
>Page #n</li>