Re: Need Replacement of some Selenium Functions in Webdriver

641 views
Skip to first unread message

Luke Inman-Semerau

unread,
Jul 8, 2011, 12:07:50 PM7/8/11
to saorabh singh, Selenium Users
Try using the WebDriverBackedSelenium class:


On Fri, Jul 8, 2011 at 8:59 AM, saorabh singh <kun...@gmail.com> wrote:
Hi,
m migrating from Selenium 1.3 to Selenium 2

I am looking for some function in webdriver which can fetch me same
results as Selenium1.3

Functions in Selenium 1.3 which need to be migrated to Webdriver are:

selenium = new DefaultSelenium(seleniumRC_IPAddress, seleniumPort,
"*"+browser, applicationURL);
selenium.start();
selenium.setContext(GenericAdapter.class.getName());
selenium.setSpeed(seleniumSpeed);
selenium.windowMaximize();
selenium.windowFocus();

please help me out with this...

Regards,
Saorabh Singh

Simon Stewart

unread,
Jul 8, 2011, 12:48:06 PM7/8/11
to seleniu...@googlegroups.com, saorabh singh
Hi,

The WebDriverBackedSelenium is really there to help with migration. If
you're using the webdriver APIs directly, you can:

* For the selenium.window* commands:
Use ((JavascriptExecutor) driver).executeScript() and call the JS
functions directly (eg: window.focus())

* setSpeed is meaningless and is a no-op in WebDriver. If you'd like
ways of slowing down tests, you need to wrap the webdriver instance.

* setContext: replace with logging using your language's normal
logging functionality.

Regards,

Simon

> --
> You received this message because you are subscribed to the Google Groups
> "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to
> selenium-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/selenium-users?hl=en.
>

Luke Inman-Semerau

unread,
Jul 8, 2011, 1:22:01 PM7/8/11
to seleniu...@googlegroups.com, saorabh singh
I'll spend some time to add to the doc's the mapping of all the commands as described by:
and all the class it uses in:

I don't see anywhere if anyone has done that yet... I guess it just seems daunting :)

saorabh singh

unread,
Jul 8, 2011, 11:59:25 AM7/8/11
to Selenium Users, luke.s...@gmail.com, ma...@ardescosolutions.com

Simon Stewart

unread,
Jul 11, 2011, 3:22:21 AM7/11/11
to seleniu...@googlegroups.com
Maybe a little daunting. Most of the time, though, the translation is
logical and simple, especially once the element is found and the
various alert handling strategies are ignored. That's the main reason
I've not written something like that already.

Simon

On Fri, Jul 8, 2011 at 6:22 PM, Luke Inman-Semerau

saorabh singh

unread,
Jul 14, 2011, 2:56:09 AM7/14/11
to seleniu...@googlegroups.com
Hi guys,
As suggested by you :: alternate for "selenium.windowMaximize()"

((JavascriptExecutor) selenium).executeScript("if (window.screen)" +"{ window.moveTo(0,0);window.resizeTo(window.screen.availWidth,window.screen.availHeight)"); 

But i am getting Exception while executing this command.
org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide any stacktrace information)
Build info: version: '2.0rc3', revision: '12536', time: '2011-06-20 18:19:52'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_24'
Driver info: driver.version: RemoteWebDriver

Please let me know what is wrong with this code.

Regards,
Saorabh Singh

Luke Inman-Semerau

unread,
Jul 14, 2011, 9:45:55 AM7/14/11
to seleniu...@googlegroups.com
You are missing an ending "}"

Try:
((JavascriptExecutor) selenium).executeScript("if (window.screen){window.moveTo(0,0);window.resizeTo(window.screen.availWidth,window.screen.availHeight)}"); 

Luke Inman-Semerau

unread,
Jul 14, 2011, 12:51:16 PM7/14/11
to Selenium Users
driver.switchTo().window(windowId)

getting the window ids available:
driver.getWindowHandles()

On Thu, Jul 14, 2011 at 9:49 AM, saorabh singh <kun...@gmail.com> wrote:
Hi all,

can you help me out to get replacement for 
selenium.selectWindow(windowID);
 I am using webdriver APIs directly.
So please help me out.

Regards,
Saorabh Singh

saorabh singh

unread,
Jul 14, 2011, 12:49:12 PM7/14/11
to seleniu...@googlegroups.com, simon.m...@gmail.com, luke.s...@gmail.com
Hi all,

can you help me out to get replacement for 
selenium.selectWindow(windowID);
 I am using webdriver APIs directly.
So please help me out.

Regards,
Saorabh Singh
On Thu, Jul 14, 2011 at 12:26 PM, saorabh singh <kun...@gmail.com> wrote:

saorabh singh

unread,
Jul 15, 2011, 9:18:01 AM7/15/11
to seleniu...@googlegroups.com, luke.s...@gmail.com, simon.m...@gmail.com
Hi,
for wait for page load function(in selenium 1) i am using(for selenium 2):
 driver.manage().timeouts().setScriptTimeout(timeout, TimeUnit.MILLISECONDS);
So my question is what is setScriptTimeout??
i am looking for this answer so that i can use this function more appropriately...
Thanks,

Regards,
Saorabh Singh

saorabh singh

unread,
Jul 15, 2011, 10:05:27 AM7/15/11
to seleniu...@googlegroups.com, luke.s...@gmail.com
For this Command 
((JavascriptExecutor) selenium).executeScript("if (window.screen){window.moveTo(0,0);window.resizeTo(window.screen.availWidth,window.screen.availHeight)}"); 

i am still getting this error:

org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide any stacktrace information)
Build info: version: '2.0rc3', revision: '12536', time: '2011-06-20 18:19:52'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_24'
Driver info: driver.version: RemoteWebDriver

Regards,
Saorabh Singh

saorabh singh

unread,
Jul 15, 2011, 10:23:41 AM7/15/11
to seleniu...@googlegroups.com, luke.s...@gmail.com
((JavascriptExecutor) selenium).executeScript("if (window.screen){window.moveTo(0,0);window.resizeTo(window.screen.availWidth,window.screen.availHeight)}"); 

Works fine for Firefox,
But Fails for IE..
any idea,why????
my code::
WebDriver selenium;
if(browser.contentEquals("firefox"))
selenium=new FirefoxDriver();
else if(browser.contentEquals("IE"))
selenium=new InternetExplorerDriver();

i have already provided error..


Regards,
Saorabh Singh

Simon Stewart

unread,
Jul 17, 2011, 1:11:07 PM7/17/11
to seleniu...@googlegroups.com, luke.s...@gmail.com
Does the JS work in IE when tried directly?

Simon

saorabh singh

unread,
Jul 18, 2011, 11:24:57 AM7/18/11
to seleniu...@googlegroups.com
hi,
Do we have alternate for selenium 1 function..
selenium.clickAt(link path ,textname).

in Selenium 2??

Regards,
Saorabh Singh

santosh h s

unread,
Jul 18, 2011, 11:28:25 AM7/18/11
to seleniu...@googlegroups.com
you ca use  driver.findElement(By.partialLinkText(linkText))
/Santosh

saorabh singh

unread,
Jul 18, 2011, 11:54:13 AM7/18/11
to seleniu...@googlegroups.com
But this command takes only one parameter...
what if same partial text is present multiple times in a page..

Paul Hammant

unread,
Jul 18, 2011, 11:55:37 AM7/18/11
to seleniu...@googlegroups.com
Add and 's' to findElement to see multiple matches.

saorabh singh

unread,
Jul 18, 2011, 12:16:38 PM7/18/11
to seleniu...@googlegroups.com
SCENARIO:

While creating a account for a user we have mail & phone fields,
FOR MAIL:
By default we have 1 text box for mail
But user has option to add more mail address
So for that we have a button with Label=Add next to default text box.

once user press Add button..we will have 1 more texbox (just below the default text box for mail) in our page for user to enter another mail address. & that text box will have a button with Label=Remove next to it.. that will give him open to remove this text box if he changes his mind(no to enter another mail).

Same has been implemented for phone..

So my Requirement,is to automate this page with various scenarios(-ve & +ve)

For that i need to click on add & remove buttons many time...
So till now (in selenium 1) i was using
selenium.clickAt(link path ,textname).
where link path = xpath of new textbox &
 to conform that we are firing click event at correct point we used button name.
this method gives us more reliability..
 
So..Do we have any function which can help me out.

Regards,
Saorabh Singh
Reply all
Reply to author
Forward
0 new messages