Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending Selenium: How to call commands?

I read about user extensions and extending selenium but am wondering how to call a command from within a custom command I'm creating.

I added a file similar to the following to Selenium core extensions (user-extensions.js) in Selenium IDE Options.

// selenium-action-example.js

Selenium.prototype.doExample = function() {
  this.doOpen("/"); // doesn't waitForPageToLoad like the command does

  // These two commands are equivalent to the clickAndWait command. NOT!
  // For proof, see the filterForRemoteControl function:
  // http://code.google.com/p/selenium/source/browse/trunk/ide/src/extension/content/formats/formatCommandOnlyAdapter.js?r=8284#68
  this.doClick("css=a#example");
  this.doWaitForPageToLoad(); // doesn't wait at all

  this.doClick("link=Example");
  this.doWaitForElementPresent("example"); // error! undefined function
  this.doClick("example");
};

In other words, how can I wait for things between clicks within a custom action?

like image 854
ma11hew28 Avatar asked Nov 06 '22 02:11

ma11hew28


1 Answers

Your command

this.doWaitForPageToLoad(); // doesn't wait at all

Doesn't wait as you have not specified wait time in brackets. You should write it as

this.doWaitForPageToLoad(30000); // time in milliseconds

Tour another Command

this.doWaitForElementPresent("example"); // error! undefined function

as no function is there in Selenium. whenever it waits for an element it checks that element is present or not so you should wait for time until it is visible/present. Using For loop and ispresent commands you can do it.

Regards

like image 135
lAH2iV Avatar answered Nov 13 '22 19:11

lAH2iV