- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
[solved]example tests
Mon Feb 06, 2012 11:02 pm
hey guys I want to start making my tests witch webdriver/eclipse and java. And I am now learning the commands.... I'm still in the beggining and I got something like this :
public class drafts {
public static void main(String[] args){
WebDriver driver = new FirefoxDriver();
driver.get("https://website/login.php");
driver.findElement(By.xpath("//*[@id='content-container']/div[1]/form/div[2]/div[1]/input")).sendKeys("admin");
driver.findElement(By.xpath("//*[@id='content-container']/div[1]/form/div[2]/div[2]/input")).sendKeys("password");
driver.findElement(By.xpath("//*[@id='content-container']/div[1]/form/div[2]/input")).click();
...........................................................
....................................
.......................................
but It's a bit hard because I don't know the basic commands. Yes I can find them in the documentation on the selenium website but Its a bit messy and hard to find the commands you need.
So I was wondering if someone can send me a few example tests so I can see the most used commands in action so I will be able to understand them easier and faster. For example If I change the above code to InternetExplorerDriver isntead of FirefoxDriver the sendKeys command seems to not work and I have no idea why. I hope someone can send me an example of a test implemented for the different browsers (firefox/IE/chrome/opera/ and Im not sure if there is support for safari in webdriver ?). Thanks. You can add the tests here or send them to my email : zlos7ar@gmail.com . Thanks again and I wish you all a great week !
public class drafts {
public static void main(String[] args){
WebDriver driver = new FirefoxDriver();
driver.get("https://website/login.php");
driver.findElement(By.xpath("//*[@id='content-container']/div[1]/form/div[2]/div[1]/input")).sendKeys("admin");
driver.findElement(By.xpath("//*[@id='content-container']/div[1]/form/div[2]/div[2]/input")).sendKeys("password");
driver.findElement(By.xpath("//*[@id='content-container']/div[1]/form/div[2]/input")).click();
...........................................................
....................................
.......................................
but It's a bit hard because I don't know the basic commands. Yes I can find them in the documentation on the selenium website but Its a bit messy and hard to find the commands you need.
So I was wondering if someone can send me a few example tests so I can see the most used commands in action so I will be able to understand them easier and faster. For example If I change the above code to InternetExplorerDriver isntead of FirefoxDriver the sendKeys command seems to not work and I have no idea why. I hope someone can send me an example of a test implemented for the different browsers (firefox/IE/chrome/opera/ and Im not sure if there is support for safari in webdriver ?). Thanks. You can add the tests here or send them to my email : zlos7ar@gmail.com . Thanks again and I wish you all a great week !
- qappbcAmateur
- Posts : 38
Join date : 2011-10-13
Re: [solved]example tests
Tue Feb 07, 2012 4:45 am
Treat this question like a defect report:
1. post ALL of your test code here (like the import lines at top)
2. What error(s) generated when run?
3. what url is it you are trying to access when IE cannot do?
a. What version #s of browsers are you driving?
Note: http://sqa.stackexchange.com/questions/1181/selenium-form-input-sendkeys-doesnt-always-work-under-ie
There is a huge amount of Selenium/WebDriver/Java in eclipse test examples available on the Internet just by doing a Google search.
1. post ALL of your test code here (like the import lines at top)
2. What error(s) generated when run?
3. what url is it you are trying to access when IE cannot do?
a. What version #s of browsers are you driving?
Note: http://sqa.stackexchange.com/questions/1181/selenium-form-input-sendkeys-doesnt-always-work-under-ie
There is a huge amount of Selenium/WebDriver/Java in eclipse test examples available on the Internet just by doing a Google search.
- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
Re: [solved]example tests
Tue Feb 07, 2012 5:07 pm
I fixed the problem with IE its ok now.
But funny why I can not find a good examples.....
For example when I export my selenium IDE tests as "JUnit 4 (WebDriver)" I get these some errors:
1. // ERROR: Caught exception [ERROR: Unsupported command [fireEvent]]
2. // ERROR: Caught exception [ERROR: Unsupported command [isTextPresent]]
3. // ERROR: Caught exception [ERROR: Unsupported command [getEval]]
In IDE they look like this:
1. fireEvent name=input_4 blur
2. assertTextPresent sometext
3. store javascript{var bool=(storedVars['lastidea']===storedVars['topidea']);bool;} bool
How can I change those to work ? There is nothing about this in google (at least I can't find it).
But funny why I can not find a good examples.....
For example when I export my selenium IDE tests as "JUnit 4 (WebDriver)" I get these some errors:
1. // ERROR: Caught exception [ERROR: Unsupported command [fireEvent]]
2. // ERROR: Caught exception [ERROR: Unsupported command [isTextPresent]]
3. // ERROR: Caught exception [ERROR: Unsupported command [getEval]]
In IDE they look like this:
1. fireEvent name=input_4 blur
2. assertTextPresent sometext
3. store javascript{var bool=(storedVars['lastidea']===storedVars['topidea']);bool;} bool
How can I change those to work ? There is nothing about this in google (at least I can't find it).
- qappbcAmateur
- Posts : 38
Join date : 2011-10-13
Re: [solved]example tests
Wed Feb 08, 2012 12:58 am
Glad you fixed the issue with IE. What was the problem and how fixed?
FYI: you should start a new post for this new problem...
Look here:
http://stackoverflow.com/questions/8120315/how-to-test-richfaces-combobox-with-selenium-webdriver
and here: (Export anomolies & conditions)
http://srackham.wordpress.com/2011/10/25/testing-coffeescript-apps-with-selenium/
The problem is the current lack of 1-to-1 mapping when you export from IDE. WebDriver becomes the domain for a programmer, where you have to look at the available choice(s) to see what will work for your specific problem. Sometimes that means, perhaps in your case in this last issue, to point to a class called 'Actions' and make use of it.
If you want specific help and can do so, give the url & your code and restate the issue in a new thread.
FYI: you should start a new post for this new problem...
Look here:
http://stackoverflow.com/questions/8120315/how-to-test-richfaces-combobox-with-selenium-webdriver
and here: (Export anomolies & conditions)
http://srackham.wordpress.com/2011/10/25/testing-coffeescript-apps-with-selenium/
The problem is the current lack of 1-to-1 mapping when you export from IDE. WebDriver becomes the domain for a programmer, where you have to look at the available choice(s) to see what will work for your specific problem. Sometimes that means, perhaps in your case in this last issue, to point to a class called 'Actions' and make use of it.
If you want specific help and can do so, give the url & your code and restate the issue in a new thread.
- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
Re: [solved]example tests
Wed Feb 08, 2012 3:32 pm
There was no issue with IE, because when I tried it on the next day it just worked. I guess I was doing something wrong the previous day but I'm not sure what Thanks for the links if I can't fix it I will start a new post.
- zlos7arAmateur
- Posts : 41
Join date : 2012-01-13
Age : 36
Location : Germany
Re: [solved]example tests
Wed Feb 08, 2012 4:03 pm
It appears that not all IDE commands are supported in "JUnit 4 (WebDriver)" so I decided to use "JUnit 4 (WebDriver Backed)" and now it works perfectly and even the code is a lot easier to understand.
Permissions in this forum:
You cannot reply to topics in this forum