can user is able to give manual input while running selenium IDE script?
For ex. If there is name field then can we open input box everytime script runs so that user can give his input for name field?
Let me know whether it is possible or not..
If yes then please suggest me a solution.
Thanks in advance
You can use the following script to invoke a javascript prompt in order to get the value
<tr>
<td>storeEval</td>
<td>prompt("Please enter your FirstName")</td>
<td>firstName</td>
</tr>
Then accessing the value is a case of using ${firstName}.
EDIT: Since Selenium IDE 2.5.0, the script needs to look like this:
<tr>
<td>storeEval</td>
<td>javascript{prompt("Please enter your FirstName")}</td>
<td>firstName</td>
</tr>
As of 2020 using Selenium IDE 3.16.1, I found the following config worked by the suggested answers above. (I re-answered the question as above answers did not clearly combined all pieces)
Command : execute script
Target : return prompt("Question Text","Default value");
Value : yourVariableName
and fill in the input box by the stored var:
Command : type
Target : (your selector)
Value : ${yourVariableName}
In Selenium IDE 2.8.0:
Capture the test session entering the login and password. Edit the Command for each and change from "type" to "waitForText" and remove the values in the Value fields previously stored for login and password. Re-run the saved test script from the IDE.
Since you specifically asked about Selenium IDE, the answer is no. But you can pause the script and let the user type their name, then have the script continue. I've heard of folks using this technique for handling CAPTCHAs, which of course are not easily automatable.
You could use the technique suggested here which uses the Selenium WebDriver and Java's BufferedReader. I don't think it can be adapted for Selenium IDE, but the technique should work fine with Selenium RC.
The basic idea is:
Issue Selenium commands up to the point where you want to capture user input.
Call the following code to capture the user input to a BufferedReader.
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
reader.readLine();
Continue your Selenium commands
(Note, if you are using C#, there is a discussion here on how to use Console.In.ReadLine(); instead of BufferedReader).
Just a minor modification to Stephen Binns response. I'm running Selenium IDE 2.5.0 and my test looks like this:
<tr>
<td>store</td>
<td>javascript{prompt("password")}</td>
<td>password</td>
</tr>
Without the javascript{} it wouldn't prompt.
The proposed solution works fine for selenium IDE (tested for 2.5)
<tr>
<td>store</td>
<td>javascript{prompt("password")}</td>
<td>password</td>
</tr>
Use Thread.Sleep(20000);
This will freeze everything for 20s and you can enter whatever fields you want to enter manually in that time period
none of the accepted answers worked for me. Here is how I solved it:
Create new command (at the top to store my variable that I wanted to use in 30 places.)
Command: execute script
Target: return "Test Iteration #13"
Value: VarName
then in the 30 places I wanted to use that variable. I put this
Value: Enter some text into the web input box and my test iteration number is ${VarName}
Related
I move my Selenium installation to a new server, since then some tests using logins no longer work.
After investigation, I found that the password field was populated with an incorrect value. Therefore the tests failed.
I'm trying to do the following :
_passWordTextBox.Clear();
_passWordTextBox.SendKeys("!!ä{dasd$352310!!!\\_XY>èà$£<?^^");
Here is how the field is populated after those lines:
The "!" character was the only one missing. It worked on the previous server. Some other suspicious characters (like $ éà<) also worked.
I've looked at locale settings (culture differences) between the servers.
From these characters sent in a Password string:
!"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
All of these worked correctly:
"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ _ abcdefghijklmnopqrstuvwxyz{|}
Only these failed to be sent correctly:
!]^`~
I've also tried in other fields (such as a Description field) and see the same failure.
I've tried to see if the command was sent correctly to the selenium server, but the logs seem to suggest it worked:
08:05:35.850 DEBUG [ReverseProxyHandler.execute] - To upstream: {"value":["!\"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~?"]}
It means that the server receives the command correctly, but for some reason the driver or the server doesn't execute properly.
Try this:
_passWordTextBox.SendKeys(#"!!ä{dasd$352310!!!\\_XY>èà$£<?^^");
Maybe is for the validates from field.
You can try using clipboard:
public static void SendValueFromClipboard(this IWebElement txtField, string value)
{
Clipboard.SetText(value);
txtField.SendKeys(OpenQA.Selenium.Keys.Control + "v");
}
This is written on C#, you will need to rewrite it in language, you are using.
After looking into multiple system settings i discovered that both my piloting and executing machine add the same regional settings (Format : French(Switzerland) , Keyboard : French(Switzerland), and I didn't look any further.
While fiddling around i discovered this setting :
As it turns out , the Language for non-Unicode programs was set to French(Switzerland) on the machine executing the tests. Changing it to English(UK) resolved the problem.
Probably a bug in chromedriver.
Your solution doesn't work for me, since I already have that setting set to English, but here's a solution I found if anyone else's interested.
Just change your keyboard to ENG UK in task bar.
I have the exact same version of selenium (2.53.6) and firefox (43.0) on a local virtualbox with Ubuntu trusty, and a trusty image on travis.
The HTML code is trivial
<div>
<i class="fa fa-close fa-2x" aria-hidden="true"></i><br>Close<br>
</div>
The test code is trivial as well
def test_start_stop_container(self):
driver = self.driver
driver.get(self.base_url + "/hub/login")
driver.find_element_by_id("username_input").clear()
driver.find_element_by_id("username_input").send_keys("test")
driver.find_element_by_id("password_input").clear()
driver.find_element_by_id("password_input").send_keys("test")
driver.find_element_by_id("login_submit").click()
driver.find_element_by_name("action").click()
self.wait_for(lambda: "noVNC" == driver.title)
driver.find_element_by_xpath("//i").click() # << this here.
self.wait_for(lambda: "noVNC" != driver.title)
driver.find_element_by_name("action").click()
driver.find_element_by_xpath("//i").click()
driver.find_element_by_xpath("(//button[#name='action'])[2]").click()
self.wait_for(
lambda: "Start" == driver.find_element_by_name("action").text)
driver.find_element_by_id("logout").click()
In both cases I use Xvfb, but only on Travis the click is not working. No exception happens. It just seems like the operation is not performed. I recorded the session on Xvfb using some ffmpeg magic, and what I see is that the link highlights in blue (which is the hover color) but then the link is not clicked.
This video shows the exact operation (starts around 20 sec mark)
Does anybody have an idea of what the problem could be, or if there's something I can do to debug it?
Actually some time click() method of WebElement doesn't work as expected due to some designing issue of the element or other issues. So in this case, here is an alternate solution provided by selenium to execute piece of JavaScript to perform further events on the element.
So can use execute_script() instead to perform click here as below :-
driver.execute_script("arguments[0].click()", driver.find_element_by_link_text("Close"))
Try this xpath to identify the href - "//a[contains(text(),'Close')]"
Kindly help.
i have created a runnable jar for my Selenium webDriver suite. now i have to test this in multiple environment( QA , Demo box, Dev ). But my manager doesnt what it to be hard coded like below
driver.get(baseUrl)
As the baseURl will change according to the need. My script is given to the build team. So all they will do in the command prompt is
java -jar myproject-1.0.1.jar
So my manager has asked me to send the baseUrl as a command line argument so that build team do not have to go to my script and manually change the baseUrl. They should be able to change the URL every time they run the script from the command line itself. Something like this
java -jar myproject-1.0.1.jar "http://10.68.14.248:8080/BDA/homePage.html"
Can somebody please guide me through this. Is it possible to send command line arguments to Selenium Web Driver driver.get(baseUrl)
Thanks in advance
From your question above I recon you want pass URL at runtime, means your URL changes time to time so beside hardcoded URL , you want pass at the time your automation code runs. So, let me give you 2 simple solutions.
You can send URL dynamically or at Run time by using javascript executor:
try{
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("var pr=prompt('Enter your URL please:',''); alert(pr);");
Thread.sleep(15000L);
String URL = driver.switchTo().alert().getText();
driver.switchTo().alert().accept();
driver.get(URL);
}catch(Throwable e)
{
System.out.println("failed");
}
Use this code in place of driver.get(); , so that a prompt box will appear when you run your code and within 15 secs or it will throw a error(you can change the time in Thread.Sleep) you will give the current Valid URL and hit Enter, the navigation will go to the URL. So that you can use different URL for same set of testscripts.
By using Scanner Class:
String url = "";
System.out.println("Enter the URL :");
Scanner s = new Scanner(System.in);
url = s.next();
s.close();
By using this you can give needed URL in your Console (If you are using Eclipse).
I recommend try Javascript excutor in your code and then create a runnable jar file and just run the Jar file, you will know and it will be the better solution than commandline URL passing . Let me know :)
Another way is to supply arguments this way -Durl=foobar.com and extract them in runtime like this
String URL= System.getProperty("url")
I'm trying to convert some Selenium HTML tests to use the WebDriver 2.0 framework. According to the web site (http://seleniumhq.org/docs/03_webdriver.html), the WebDriver framework no longer supports the "browserbot" Javascript variable. So my question is, how do I convert a command like
<tr>
<td>verifyEval</td>
<td>this.browserbot.getUserWindow().s.pageName</td>
<td>Config_6_Summary_Confirm_EX</td>
</tr>
using WebDriver? When I run the command
String target = selenium.getEval("this.browserbot.getUserWindow().s.pageName")
commnand, I get an exception stating, "this.browserbot is undefined". Thanks, - Dave
I make a suggestion to following.
String target = selenium.getEval("window.s.pageName")
You can access to 'browserbot' from WebDriver's getEval by "selenium.browserbot".(not "this")
selenium.getEval("typeof(this.browserbot)"); // undefined
selenium.getEval("typeof(selenium.browserbot)"); // object
but, can not use some browserbot function.
(I don't know the deference of 'enabled function' and 'disabled function'. sorry)
"getUserWindow()" is disabled.
You can use a "window" instead of it.
I am using Selenium IDE to record some scenarios and wanted to check if a particular text is present on the page. I inserted a command "VerifyTextPresent". However, it always returns the result as true even when the particular text is not present.
What can be the probable reason? Do I need to modify anything?
Looking at the sourcecode it looks like you are putting the text you are searching for in the incorrect field.
verifyTextPresent (and assert...) has only two parameters unlike verifyText which also requires a target.
Unlike verifyText the text element you are searching for should be entered into the second field 'Target' not in 'Value'.
thus the code becomes
<tr>
<td>verifyTextPresent</td>
<td>XYZ</td>
<td></td></tr>
I made the same mistake when learning Selenium as the field names are misleading!
Selenium assertions have different modes:
All Selenium Assertions can be used in
3 modes: "assert", "verify", and
"waitFor". For example, you can
"assertText", "verifyText" and
"waitForText". When an "assert" fails,
the test is aborted. When a "verify"
fails, the test will continue
execution, logging the failure.
Try assertTextPresent. This should abort the test immediately.
check that page : http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/java/com/thoughtworks/selenium/SeleneseTestBase.html#assertTrue%28boolean%29
assert and verify text fields build boolean results with using resource code.