I have the following selenium markup:
<tr>
<td>type</td>
<td>css=input.some-text</td>
<td> "Some text here, which has to be randomized" </td>
</tr>
I want the text to be a random number rather than a fixed string. Is it possible to achieve this using the Selenium IDE alone?
<td>type</td>
<td>css=input.some-text</td>
<td>javascript{"uvu" + Math.floor(Math.random()*15000) + "#gmail.com";}</td>
In above I just show you example for random email. You want other value if so you can customize it.
Related
I want to generate the filename parameter of the captureEntirePageScreenshot command in Selenese through javascript. Is that possible?
The scenario is that I want to take a screenshot of every page that is opened, and the name of the webpage is generated dynamically and encodes some information.
Combine it in javascript:
<tr>
<td>storeEval</td>
<td>Date.now()</td>
<td>timestamp</td>
</tr>
<tr>
<td>storeEval</td>
<td>"SomePrefixScreenShot" + storedVars['timestamp']</td>
<td>filename</td>
</tr>
<tr>
<td>echo</td>
<td>${filename}</td>
<td></td>
</tr>
This can be done by using the "storeEval" command to generate the name, followed by the original "captureEntirePageScreenshot" command that uses the variable defined in "storeEval" as the parameter.
I hope it saves someone 30 mins :)
I got this page where I want to run my code:
I got a css with this properties:
<center>
Radicacion Exitosa, Numero Radicacion: 12 - 132263…
</center>
I want to store the "132263" in a variable because I have to copy and paste them in another window, so I want to know if there is a way to only get the number from that tag...specially the "132263" because if I store a Variable Selenium IDE only will get the full text.
Thanks
Using regex in javascript will do this for you:
<tr>
<td>storeText</td>
<td>//center</td>
<td>full</td>
</tr>
<tr>
<td>storeEval</td>
<td>var regex=/\-\s+(\d+)\s+\-/;regex.exec(storedVars['full'])[1];</td>
<td>number</td>
</tr>
<tr>
<td>echo</td>
<td>${number}</td>
<td></td>
</tr>
We're capturing the text from the CENTER tag and then running the regex to grab the number out of it (using the group (\d+) and returning [1]).
I try to check the sending tweets (twitter.com) using seleniumIDE, but I ran into a problem. Textbox for tweets - div element. SeleniumIDE allows to write text only into input element? I tried to use the type id=tweet-box-home-timeline test tweet command, but it does not work. Which command should I use to write text into a div?
The below is working for me. This is after you have logged in.
<tr>
<td>clickAt</td>
<td>xpath=(//div[#id='tweet-box-home-timeline'])</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>selenium.browserbot.findElement("tweet-box-home-timeline").innerHTML='The Lord is my shepherd I shall not want he leads me';</td>
<td>myval</td>
</tr>
<tr>
<td>click</td>
<td>xpath=(//button[#class='btn primary-btn tweet-action tweet-btn js-tweet-btn'])</td>
<td></td>
</tr>
Best I could manage was manipulating it via java script:
document.getElementById("tweet-box-home-timeline").innerHTML='abc';
You better use Java, Selenium IDE isn't useful tool.
I've tested Selenium IDE with twitter fields, unfortunately it doesn't work.
It works for me:
driver.get("https://twitter.com/");
driver.findElement(By.id("signin-email")).sendKeys("YOUR LOGIN");
driver.findElement(By.id("signin-password")).sendKeys("YOUR PASSWORD");
driver.findElement(By.xpath("//button[#class='submit btn primary-btn flex-table-btn js-submit']")).click();
driver.findElement(By.id("tweet-box-home-timeline")).sendKeys("Test");
Give it a try.
I got in my site several amounts of money displayed like this: $5,000
I want to sum all of them and to check some variables. How can I parse and get the number 5000 and use it as a number (summing up, multiplying etc) using Selenium IDE?
You can use storeEval and parse the string into the Number using javascript:
<tr>
<td>storeEval</td>
<td>Number('$5,000'.replace(/[^0-9\.]+/g,""));</td>
<td>amount</td>
</tr>
<tr>
<td>echo</td>
<td>${amount}</td>
<td></td>
</tr>
I'm writing test cases for a webpage that has a table as the main focus of the page. I'm checking that the page contains a new entry via the Page Should Contain fucntion, I then want to find the xpath for this element. I am doing this because each entry is added to the end of the table so I cannot set a static xpath for it because I don't know how many entries will be added between each run of this particular test.
Thanks in advance.
<table class="fw-table">
<thead>
<tr class="affix-header">
<th class="columnwidth-description">Email</th>
<th>Account</th>
<th>Signed up</th>
<th>Number of invalid attempts</th>
</tr>
</thead>
<tbody>
<tr>
<td>devtest</td>
<td>Account</td>
<td>true</td>
<td>0</td>
</tr>
<tr>
<td>test#testing.com</td>
<td>Account</td>
<td>true</td>
<td>1</td>
</tr>
search for: xpath=//body/div[2]/div/div[2]/div[2]/div/div/table/tbody/tr[1]/td[1]
If you need to verify that last table row contains certain text you can use the Page Should Contain Element keyword and provide an xpath locator which will find the last table row containing your text:
Page Should Contain Element xpath=//table[#class="fw-table"]//tr[last()]//td[contains(text(),'bottomline')]