Export test case as - Java / JUnit /Webdriver using latest Selenium IDE - selenium

Is there an option to export the tests as "Java / JUnit /Webdriver" or 'Enable Webdriver Playback' option using latest Selenium IDE? I added this extension to my Firefox browser and I don't find these options. It actually saves the file as testName.side format. When I open this file in EclipseIDE, it is actually in a JSON format.
I have a requirement where I need to quickly navigate through all the links across multiple pages and I thought SeleniumIDE will be the best option where I can use the 'Enable Webdriver Playback' option and run it in all the browsers.
Any thoughts on this?
Here is the link to the Selenium IDE documentation SeleniumIDE_Documentation

At the time you asked the question it was probably not possible with Selenium IDE 3.
But now you can right click on a test-name in the test list, and select the option to 'Export' it to a Java JUnit test.
Please ensure that the 'mode' of the IDE (below the project name) is set to 'Tests' and not 'Executing' when you perform the right click.
See more information in the documentation

Related

How to choose which monitor Robot Framework will display test execution?

I'm currently working with 2 monitors, and I've noticed that Robot Framework (using SeleniumLibrary) always open the test execution in the main display that is selected in windows display settings.
Is there any way to choose which monitor will be used to display test execution?
This is how I'm starting the browser. I'm currently using Chrome
Start Browser
Open Browser ${url} ${BROWSER}
... options=add_experimental_option("excludeSwitches", ["enable-logging"])
Maximize Browser Window
Ragnoroct's answer here seems to be a solution: https://stackoverflow.com/a/57545639/16635196.
Chrome has a command-line switch for window position
--window-position=x,y
https://peter.sh/experiments/chromium-command-line-switches/#window-position
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('window-position=2000,0') # opens at x=2000,y=0 from the start
driver = webdriver.Chrome(options=options)
Since I was not using Python directly in the Robot tests, I resorted to directly modifying the Python package source where these options are set. For example, AppData\Local\Programs\Python\Python310\lib\site-packages\QWeb\internal\browser\chrome.py for combination of QWeb and Windows10. Obviously not a good way of doing things in the long run, but virtual environment could be of help here.
Start-maximized didn't work in conjunction with window-position, so I had to additionally use window-size=2560,1440.

JMeter with Webdriver Sampler - Browser window not opening

I am running Jmeter with the Webdriver plugin installed on Windows 7. My current test plan contains the Webdriver sampler and Firefox driver config. When I try to run the test plan, nothing happens. There is nothing recorded in the View Results Tree window, and the remaining test indicator in the top right hand corner counts down to 0 without anything happening.
When I deactivate the Webdriver Sampler and Firefox driver config elements, the remaining tests run without a problem.
Is there a bug with this software, or am I missing something? My code is below, if that helps.
var pkg = JavaImporter(org.openqa.selenium)
WDS.sampleResult.sampleStart()
WDS.browser.get('https://test.test.test.test') var username =
WDS.browser.findElement(pkg.By.id('USERNAME')).sendKeys([WDS.args[0]])
var password =
WDS.browser.findElement(pkg.By.id('PASSWORD')).sendKeys([WDS.args[1])
WDS.sampleResult.sampleEnd()
I have installed firefox 26, as this is the recommended supported browser, so it's not that there's no compatible browser.
My main question is this - Why doesn't the browser window open? Why do the other tests in the test plan fail to run when the config elements are active?
In 99% of cases the answer should be in jmeter.log file. In the meantime a couple of recommendations:
add the following line to system.properties file (lives in the /bin folder of your JMeter installation)
webdriver.firefox.bin=/path/to/your/firefox.exe
See https://code.google.com/p/selenium/wiki/FirefoxDriver page for other Firefox-related properties
locate all duplicate http* libraries like httpcore*.jar httpmime.jar etc. and remove the ones with lesser version
restart JMeter to pick the property and the changes up
Check out The WebDriver Sampler: Your Top 10 Questions Answered guide for other tips and tricks
You need to make sure you provided the full path of the Firefox driver in the jp#gc config element.

Selenium Webdriver - How to use Robot Framework with Java

I want to use robot framework with java in Eclipse IDE. i have installed robot framework in Eclipse IDE. How to write script by using robot framework with Selenium web-driver.
If you want to use eclipse as an IDE to write your tests you can use this plugin:
RobotFramework-EclipseIDE
If your goal is to write a java method then call it from robotframework you can use Remote library.
Here are the supported formats writing robotium tests:
Robotium Test Data Sytntax
You can also use maven to run robotframework test from maven project in eclipse:
Robotframework Maven plugin
If you want to write user defined keywords in java which can be used in robot script, import "AnnotationLibrary".
Link is mentioned below and follow the steps AnnotationLibrary
.
try this way.
i am using python language to write test case. python is best way to write a test cases.
my test case file name is test_google_page.robot put this code to test_google_page.robot file and save it. next open command line and go to test_google_page.robot file path and run this command
[user#localhost google_test]$ pybot test_google_page.robot
then you can seen your test case result.
*** Settings ***
Documentation your document
Library Selenium2Library
*** Variables ***
${Url} https://www.google.lk
${Browser} chrome
${Delay} 3s
*** Test Cases ***
load google page
[Documentation] your test case document
OPEN BROWSER ${Url} ${Browser}
Input text id=lst-ib robot framework
sleep ${Delay}
# click button id=<button_id>
# Page Should Contain loglevel=INFO text=<content>
Capture Page Screenshot filename=test_result.png
[Teardown] CLOSE BROWSER

Selenium Test Results are empty [duplicate]

I'm trying to run an HTML testSuite with Selenium RC. The browser starts, the first test runs, and it stops. It doesn't continue to the second test case. I named both the test cases with .html extension. I am using Firefox.
If I run them manually, individually from the selenium RC test runner window they run ok. What am I missing, this seems pretty simple but yet I'm not able to get this working.
I am using Selenium RC 1.0.3
java -jar selenium-server.jar
-firefoxProfileTemplate"C:\Users\sicky\AppData\Roaming\Mozilla\Firefox\Profiles\zvt0jj7c.default"
-htmlsuite "*firefox" "https://4.17.8.9/" "C:\Users\sicky\Documents\selenium scripts\suite.html"
"C:\Users\sicky\Documents\selenium scripts\results.html"
What am I missing?
ok I figured this out. What I was doing was , I was converting the existing scripts into HTML. Apparently it doesnt work that way. It looks like I have to name them with html extension when I make those test cases itself, then the whole suite will run –
Actually I had the same behaviour and my test scripts were in fact created in Selenium IDE and had the proper .html extension.
However! The test suite itself didn't have the .html extension. I just added it and it started working properly.

selenium RC and Flow control

Currently I am working on selenium IDE, now I need to switch to selenium RC. I have downloaded selenium server.But I really don't know how to proceed further. Even I am not able to start server from command prompt. I have used C:\Selenium RC\selenium-server\jave -jar selenium-server.jar, but it struck in between and not proceeding further..
I am looking for language java or PHP.
Let me know how should I move further for successful execution of scripts by using selenium RC
First of all: save a test suite in Selenium IDE (File > Save Test Suite). You should generate test suite - it will contain information about test cases (which, of course, should also be saved (File > Save Test Case)).
Then you are ready for testing with Selenium RC.
Try it with below command:
java -jar path/to/selenium-server-standalone.jar -htmlsuite "*firefox" "http://google.com" "path/to/your/testsuite1" "path/to/result.html"
result.html - this file will be generated during/after execution.
Be sure that name of browser, URL and paths to test suite and result file are in the quotation marks.
I am using Selenium with PHPUnit. I have got class called, lets say, somethingTest (test classes must have 'Test' at the end of their names) and extended PHPUnit_Extensions_SeleniumTestCase. This class contains several test cases as methods (e.g. function testSomeMethod1() - 'test' at the beginning).
And I run it by command:
phpunit somethingTest.php
As to the second thing:
Unknown command: gotoIf
You should load gotoif extension by adding to the execution command something like: -userExtensions path/to/extension-file
This indicates a JavaScript file that will be loaded into Selenium.
If you choose Java to write code, a better approach would be using an IDE like Eclipse. Once you link the JARs and import them in your Java classes you can write your code quickly and efficiently. On top of that, Ecplise has lot of plugins for testing software like Junit, TestNG's to help you create better test suites. Not to mention a Java IDE is always helpful in debugging test code. Here is a tutorial on how to setup Eclipse with Selenium: http://selftechy.com/2011/05/31/setting-up-selenium-with-eclipse
Hope it helps.