Using Selenium IDE how to navigate to URL - selenium

I'm new to selenium so I've been using the IDE to create tests. I have this problem where Selenium sees a button associated with a drop down menu, but it won't click the button. To get around this i want Selenium to type the URL (for the button i want clicked) into the address bar of fire fox, or I want selenium to just go to said URL via some command, but i can't find said command, and i can't get Selenium to click and type in the address bar.

You can use open command and type the expected url. Just right click on the command window and Insert New Command and follow the screenshot. However, you should find a better way to click the button instead.

I found the open(url) command after i posted this.

The open command would be the way to go here, but might I reccomend also adding in a store command, rather than having the script reference the URL directly. If for any reason the URL on the button changed it would mean amending the script, however if for example you went with
<tr>
<td>storeAttribute</td>
<td>id=Button-Locator#href</td>
<td>url</td>
</tr>
<tr>
<td>open</td>
<td>${url}</td>
<td></td>
</tr>
It would mean less upkeep on the script in the event of URL changes

Related

Entering text with Selenium IDE in TinyMCE working when clicking 'Find' button, but not when running

I am trying to use Selenium IDE to enter text in a TinyMCE text field, and have come across some code that seems like it will work, but so far it's only half-working.
What I have is:
...
<tr>
<td>selectFrame</td>
<td>id=message_ifr</td>
<td></td>
</tr>
<tr>
<td>runScript</td>
<td>document.getElementById('tinymce').innerHTML="I am typing into the Draft Section, I hope";</td>
<td>Editor</td>
</tr>
...
When I run the first command, it selects the iFrame, but nothing happends when I run the second command, nothing happens. However, when I click the 'Find' button on the target, the text is entered in the TinyMCE text area, so it looks like it's working on some level.
Anyone see where I'm going wrong?
Code came from this page:
https://groups.google.com/forum/#!searchin/selenium-users/ide$20tinymce/selenium-users/0FBmA6TUQ4s/2kaAdeU7CgAJ
It is tricky to enter text into TimyMCE text boxes. There are two steps involved in handling this task using selenium.
Switch to the frame in which the text box is present
Using Javascriptexecutor to enter the text into the same.
Please refer to the similar link in stackoverflow.
How to input text into tinceMCE editior using selenium/webdriver
Hope this helps.
This is ugly but it will work (based on the example at https://www.tinymce.com/)
<tr>
<td>runScript</td>
<td>tinymce.setActive(tinymce.get('mce_0'));tinyMCE.activeEditor.setContent('<h1>some text</h1> TinyMCE');</td>
<td></td>
</tr>
And if you're wondering what id to use (in this example in the .get I used mce_0) you can click into your tinymce text box and then run this in the console: tinymce.activeEditor.id;

Selection of Radio Button-Selenium IDE

I am new to Selenium IDE and need help in selection of radio buttons here. In my case, I am trying to generate a test case for a particular form consisting of radio buttons. When I run the command to select one of the radio buttons singly, the function works but if I run the whole test case then the radio button do not get selected and gives error of Element Id not found. Here is my html:
<input type="radio" value="0" id="ProjectSolutionsProject0" name="data[Project][solutions_project]">
My IDE command: click Target:id=ProjectSolutionsProject0 .
I tried verifyByValue , assertValue but nothing is working. Please help
From what you are describing, it appears the element may not be ready quite yet when you are trying to run the step. I have found that if an element is being dynamically generated it may take it longer to show up than Selenium wants to wait. There is a few ways to possibly fix this:
Use the waitForElementPresent command where id=ProjectSolutionsProject0 right before your current one to ensure that element has time to load.
Whatever command before that try changing it to a ...AndWait command instead to give the page time to load
Lastly you could try the waitForPageToLoad command right before this command and see if that allows the page to fully load first.
I recommend trying those options in that order to see which one would solve your problem.

Selenium IDE - click appears to work but not getting recorded in the database

I'm using Selenium IDE on this website: http://sg.sensemaker-suite.com/collector/modifyfragment.gsp
to do data-driven entry using an XML file.
My test suite runs a loop using data from the XML file where it:
1. Enters the user name, project, language, and the ID. Clicks "load fragment"... loads and page numbers pop up.
2. Click "16" and waits to load.
3. Enters text in a field and then final click to "save modified fragment".
4. Captures a successfully entered alert.
I've created the test suite and it appears to be working when I watch it run on FireFox. Everything gets entered properly and clicked and it loops properly to the end. However, when I go back into the database, the data I entered isn't there. Could it be my last click and alert capture are incorrect?
<tr>
<td>waitForElementPresent</td>
<td>name=ModifyFragment</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=ModifyFragment</td>
<td></td>
</tr>
<tr>
<td>assertAlert</td>
<td>Your entry saved successfully</td>
<td></td>
</tr>
I've tried different last methods ClickAt, MouseOver, MouseDown, MouseUp. Nothing works.
When I enter everything manually, it works. However when I use Selenium to do everything but the final click and then click it manually myself, it doesn't register in the database. Any ideas on what else I can try?

Run Selenium tests in new window

I am trying to record a test using Selenium GUI (in Firefox). The application uses an image as hyperlink as shown below:
<a class="mainheading" align="center" target="_blank" href="https://myapps.web.com/prepaid/customer/index.jsp">
<img width="256" height="57" border="0" alt="customer" src="images/customer.jpg"/>
</a>
Now, when we click on above image, the a href tag opens another window. Once the new window is open, I need to perform rest of the tests in that window. The problem is when I record the test, the Selenium GUI has no way to understand that whatever actions I am performing is in the new window. Therefore, even though it records the actions appropriately, when I run a pre-recorded test, I get an error saying that the element not found. I figured that this happens because Selenium tries to find the element in the original window only (and not in the new window that got opened due to above a href).
I tried to Google, but the solutions I got were not matching to my situation above (i.e. a href opens new window as opposed to window.open). Can someone please advice?
Thank you.
You can use the driver window handles like so:
// Get a list of window identities
List<string> windowIdentities = driver.WindowHandles.ToList();
// Switch control over to the other window
driver.SwitchTo().Window(windowIdentities[1]);
This is written in C#, but it shouldn't be too different if you're writing it in a different language. Let me know if this works for you!
You would need to move to the new window before you perform actions to it. For that, you can use switchTo.window if you are using webdriver, else in ide, there should be selectwindow to move to the appropriate window and then continue your actions there.

click on script generated div in selenium

i am trying to click on a div like
[//div[24]/div/div/div/table/tbody/tr/td[3]/div/div[2]/div[2]/div[5]/div/div] .. although selenium verifies this div by verifyElementPresent and xPath is shown in xPath finder but click function of selenium does not click on it ..
selenium opens a page, i click on Customers link, script generates all the customers, then click on Details, script generates the detail page,. there i have to click on the div (Save button actually ) mentioned above ... any solution for this ???
try runScript and fire the click event with javascript
e.g. if you have jQuery on the tested script
<!--fire awkward click event-->
<tr>
<td>runScript</td>
<td>$('.bo-selector').click();</td>
<td></td>
</tr>