disha
disha

Reputation: 51

How to slow down the speed of execution?

I am using selenium web-driver with testing. I want to slow down the speed of execution.
Here is the sample code:

@Parameters({ "provider_name", "branch", "address", "clientId", "website", "UserName", "Password", "Dpid" })
public void addDematAccount(String provider_name, String branch, String address, String clientId, String website,
        String UserName, String Password, String Dpid) {
    driver.findElement(By.xpath("//a[contains(@href, '#/app/DematAccount/Add')]")).click();

    setParameter(provider_name, branch, address, clientId, website, UserName, Password, Dpid);

    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

I have used driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); and Thread.sleep(2000); but not helping

Upvotes: 0

Views: 7740

Answers (4)

Samiksha
Samiksha

Reputation: 1

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

serv_obj=Service("C:\Browserdrivers\chromedriver_win32\chromedriver.exe")
driver=webdriver.Chrome(service=serv_obj)

driver.get("https://www.nopcommerce.com/en")
driver.maximize_window()

Upvotes: 0

colin
colin

Reputation: 613

If you want to view it, and its too fast I would think you could maybe record your test being executed and then review it ?

See here : http://www.seleniummonster.com/boost-up-your-selenium-tests-with-video-recording-capability/

And here : http://unmesh.me/2012/01/13/recording-screencast-of-selenium-tests-in-java/

Here is some examples from the above link

public void startRecording() throws Exception
{
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
this.screenRecorder = new ScreenRecorder(gc,
new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey,      ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,DepthKey, 24,       FrameRateKey, Rational.valueOf(15),QualityKey, 1.0f,KeyFrameIntervalKey, 15 *   60),new Format(MediaTypeKey,MediaType.VIDEO, EncodingKey, "black",FrameRateKey,       Rational.valueOf(30)),null);
this.screenRecorder.start();
}
 public void stopRecording() throws Exception
{
this.screenRecorder.stop();
}

The whole purpose of automated tests ( in my opinion ) is so they can be run in the background without user interaction/without being viewed. Also, if you want to do as many tests as possible in a certain about of time speed and parallized testing is essential. If you want to view your tests being executed I think the above method would be good to ensure you don't ruin the performance of Selenium and view the execution when completed, you will have full control with the video to replay etc.

Upvotes: 1

Yu Zhang
Yu Zhang

Reputation: 2149

If you really want to execute your program slowly or even step by step, you can try the following approaches:

  • execute your program in debug mode one step at a time;
  • refactor your code into function blocks, only execute a block of code at one time, you will not see you code being executed slowly as in time, but it becomes easier for you to associate your codes with the results.

Upvotes: -1

Bhargav Krishna
Bhargav Krishna

Reputation: 11

There is no longer any way to control the speed of each "step" in Selenium WebDriver. At one time, there was a setSpeed() method on the Options interface (in the Java bindings; other bindings had similar constructs on their appropriately-named objects), but it was deprecated long, long ago. The theory behind this is that you should not need to a priori slow down every single step of your WebDriver code. If you need to wait for something to happen in the application you're automating, you should be using an implicit or explicit wait routine.

Upvotes: 1

Related Questions