!!

Welcome to Selenium Webdriver Forum

As a web user you can read and search through forum content. Once you have registered and signed you can post topics, post replies, set up watch lists, modify forum settings, and use private messaging.

Author Topic: Is it a good habit to find corresponding method when switching from selenium1 to  (Read 1400 times)

Athrun.S.Zala

  • Web User
Hi,
 I am a new user of webdriver.
 
I already have my regression test framework using selenium 1.0.3, but
 since webdriver can support Firefox4 and IE9 better, I decided to
 upgrade the present framework using webdriver.
 
Whenever I translate a method using selenium 1 to a new one using
 webdriver, I always look for a corresponding method in webdriver to
 replace selenium 1 method. E.g., when I want to translate
 selenium.GetText(), I search google for "webdriver gettext", and find
 out webdriver.FindElement().Text. But I have to admit, in most
 situations, it is somewhat hard to find a accurate corresponding
 method...
 
My question is, is it a good behavior to do like this? Will the
 architecture of selenium 1 affect my understanding of webdriver? What
 if I am a newbie of automation testing who uses webdriver at the very
 beginning?

Athrun.S.Zala

  • Web User
Is there a good way to get started with webdriver when switching from
 selenium 1, please?

darrell

  • Web User
Selenium 2.0 contains the code for Selenium 1.0 and for WebDriver. I
 would recommend using the new jar files to run your old code. Any new
 test cases you write could be written using WebDriver. As you do
 maintenance on the old 1.0 code, convert it to 2.0, i.e. WebDriver.
 Basically, if the old code does its job, there is no value in writing
 it again in a different format.
 As far as how to write WebDriver test cases, the design of WebDriver
 is very different from Selenium 1.0. WebDriver is a lot cleaner and
 more simple but it expects you to be a programmer rather than relying
 on the record and playback features of Selenium IDE.
 
On May 30, 8:52 pm, "Athrun.S.Zala" <athrun...@gmail.com> wrote:
 

- Show quoted text -

Selenium Webdriver


Athrun.S.Zala

  • Web User
The problem is, when converting them into webdriver, I always get
 confused cause I cannot find webdriver methods corresponding to
 selenium 1 methods. I found out that It almost break all the code
 structure if I want to convert the test cases into webdriver test
 cases.
 On May 31, 10:05 pm, darrell <darrell.grain...@gmail.com> wrote:
 

- Show quoted text -

Rostislav Matl

  • Web User
I wrote a serie of short posts just for you :)
 http://rostislav-matl.blogspot.com/2011/03/moving-to-selenium-2-on-we...
 Just be warned - moving to WebDriver does not mean only rewriting API
 calls,
 depending on your code it could lead to adding a lot fo conditional
 waits you did not
 recognized as important before and bypassinging some bugs/
 deficiencies.
 I my case the effort was maybe 1:5 (API rewrite : fixes), but it
 includes replacing
 of vast number of unconditional wait by conditional ones.
 
Still, I do not regret the effort.
 
On Jun 1, 8:13 am, "Athrun.S.Zala" <athrun...@gmail.com> wrote:
 

- Show quoted text -

Samantha

  • Web User
I'm doing c# and selenium2. I create an instance of one of the drivers
 and stuff it into a variable of type iWebDriver but I cant find many
 of the methods used in Rostislav's articles... Is this because I'm
 doing c# or because I'm using a different version?
 Back on topic.... I used the migration from 1.0 to 2.0 as an
 opportunity. I started by writing methods that mimicked the stuff I
 used in selenium 1  then I added some wrappers that adjusted things to
 a more logical approach (at least in my mind). In the end I'm getting
 to a point where I use the wrappers almost exclusively.
 
For example: I wrote a method that I hung off of my page object base
 class called GetElementValue() that receives a "full locator string"
 as a parameter.  The locator string construct is just like what
 selenium 1 used (like xpath=//table/tr/td[@id=sample] or id=fred) and
 my base class has methods to convert the locator string into the
 appropriate "FindElement" and "By".... I also have methods like
 ClickElement(FullLocatorString) and
 GetAttributeValue(FullLocatorString,AttributeName) and
 SetElementValue(FullLocatoString,NewValue)...since they are in the
 base class all of my page objects can (and do) use them.
 
If you liked the way that selenium one worked you can certainly make
 methods that provide that functionality.
 
On Jun 3, 6:04 am, Rostislav Matl <rostislav.m...@gmail.com> wrote:
 

- Show quoted text -

Daniel Wagner-Hall

  • Web User
On 3 June 2011 15:57, Samantha <h...@informz.com> wrote:
 
> I'm doing c# and selenium2. I create an instance of one of the drivers
 > and stuff it into a variable of type iWebDriver but I cant find many
 > of the methods used in Rostislav's articles... Is this because I'm
 > doing c# or because I'm using a different version?
 

What methods can't you see? Some of them are properties, rather than
 methods, in C# because it's more natural (e.g. driver.Url,
 driver.PageSource), but they're all there...

reshmageo

  • Selenium User
  • *
  • Posts: 27
Good post..But could anyone ,In order to make the script written in Selenium 1 to web driver code,how to create a Jar file ,so that in can be imported..

SeleniumWebdriver Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 927
I am not sure about the code conversion in Java from Selenium 1 to Webdriver; but i have done something very similar in C#. I was able to over ride most of the commands.

Here are some links:
http://www.seleniumwiki.com/category/webdriver/

But if you have a specific command let me know.

reshmageo

  • Selenium User
  • *
  • Posts: 27
I would like to know the Java web driver script to test if the focus of a particular page is on the required text box

SeleniumWebdriver Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 927
driver.switchTo().activeElement();
returns the currently focused element. If the current element is the one you are looking for then return true. best is it put it in a try and catch.

reshmageo

  • Selenium User
  • *
  • Posts: 27
driver.switchTo().activeElement();
returns the currently focused element. If the current element is the one you are looking for then return true. best is it put it in a try and catch.


Good one...the objective is to check if the focus of the login page is in text name with id=Username.Any idea how to do that?
What does the statement driver.switchTo().activeElement(); return..String/Boolean value

SeleniumWebdriver Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 927
Try this if you want to click on the active element.

WebElement activeelement= driver.switchTo().activeElement();
activeelement.click();

reshmageo

  • Selenium User
  • *
  • Posts: 27
Try this if you want to click on the active element.

WebElement activeelement= driver.switchTo().activeElement();
activeelement.click();


Perfect code.. ;D

Now,how do we write for "Verify that username and password text box is present and  should be by default blank"
I  sorry if im troubling with my question,its just because im new..Hope its understood

SeleniumWebdriver Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 927
Check this link: http://www.seleniumwiki.com/webdriver/using-selenium-iselementpresent-in-webdriver/

I would suggest you to post a separate request rather than posting it under this subject. It will help others like you.

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
569 Views
Last post February 22, 2012, 06:13:09 PM
by Mohit Grewal
7 Replies
828 Views
Last post April 01, 2012, 08:27:02 PM
by Krishnan Mahadevan
1 Replies
409 Views
Last post April 04, 2012, 04:21:56 PM
by Simon Stewart
1 Replies
438 Views
Last post April 09, 2012, 04:53:02 PM
by Simon Stewart
2 Replies
349 Views
Last post May 01, 2012, 10:36:56 PM
by shw
Good

Started by abeabro ISTQB Certification

1 Replies
230 Views
Last post May 07, 2012, 08:01:51 PM
by reghu_nous
1 Replies
568 Views
Last post May 17, 2012, 10:12:27 PM
by Daniel Wagner-Hall

Review www.seleniumwebdriver.com on alexa.com