How to increase browserstack.idetimeout beyond 5mins, which has the maximum limit of 5 mins? - selenium

Running selenium test in browstack, have an scenario where an backend datasetup runs more then 5mins, but the browserstack.idetimeout has maximum limit of 5 mins, how to increase the BS idle time limit?

The maximum supported value for IDLE_TIMEOUT is 300 seconds (5 minutes). Should the need arise, you can add dummy commands such as fetching the page title which should reset the counter/timer after every command.
Something on the lines of:
Thread.sleep(30000);
driver.getTitle();
Thread.sleep(30000);
driver.getTitle();
Thread.sleep(30000);
driver.getTitle();

Related

How to use assertions for multiple scenario in gatling?

Right Now I am trying to do performance testing of all my api's.I already created one feature file having different scenarios(every scenario having different tag).Now I want to do use assertions on mean ResponseTime with different scenarios different assertions.
val Performance1 = scenario("Performance1").exec(karateFeature("classpath:mock/Testing1.feature#Performance"))
val Performance2 = scenario("Performance2").exec(karateFeature("classpath:mock/Testing2.feature#v3ContentMeta"))
val v4SearchTest = scenario("SearchTest").
group("SearchTesting") { exec(karateFeature("classpath:mock/Testing1.feature#Performance"))
}
setUp(
(Performance1.inject(rampUsers(10) over (5 seconds)).protocols(protocol)),
Performance2.inject(rampUsers(10) over (5 seconds)).protocols(protocol)
).assertions(details("SearchTesting").responseTime.mean.lte(680))```
You can add Gatling assertions as Global asserts. This will perfectly work with Karate Gatling. This is a sample scenario which we tried
setUp(
firstScenario.inject(
nothingFor(5 seconds), // Pause for a given duration
atOnceUsers(10), //Inject 10 Users at once
constantUsersPerSec(10) during (20 seconds), // Induce 10 requests on every second and continues this process for 30 seconds
rampUsers(10) over (10 seconds) // Linear Ramp up of the user
).protocols(protocol),
secondScenario.inject(
nothingFor(10 seconds), // Pause for a given duration
atOnceUsers(20), // Inject 10 Users at once
constantUsersPerSec(10) during (10 seconds), // Induce 10 requests on every second and continues this process for 40 seconds
).protocols(protocol),
thirdScenario.inject(
nothingFor(15 seconds), // Pause for a given duration
rampUsers(20) over (1 minute) // Linear Ramp up of the user
).protocols(protocol),
fourthScenario.inject(
nothingFor(20 seconds), // Pause for a given duration
constantUsersPerSec(10) during (20 seconds), // Induce 10 requests on every second and continues this process for 20 seconds
).protocols(protocol)
).assertions(
global.responseTime.max.between(100, 5000),
global.failedRequests.percent.is(0),
global.successfulRequests.percent.gt(90)
).maxDuration(10 minutes) // Configuring the maximum duration of your simulation. It is useful when we need to bound the duration the simulation when we can’t predict it.
The global asserts will be displayed as a separate section in the Gatling reports. This is a useful feature of Karate Gatling. Test specific failures will also get displayed in the report of Karate Gatling. For example, if this is your scenario
Scenario: My First Sample Scenario
Given url endpointUrl
And header karate-name = 'Feature 1_Scenario3'
When method get
Then status 200
And if the status code is not responded as 200, this also gets recorded in the Karate Gatling reports.
Asserts in Gatling: https://gatling.io/docs/current/general/assertions/#scope

Choose CORS Access-Control-Max-Age value

My API is configured to cache CORS preflight request by using the HTTP header Access-Control-Max-Age. The value is set to 600 seconds. I chose this value because according to Mozilla documentation this is the maximum allowed by Chrome.
Maximum number of seconds the results can be cached.
Firefox caps this at 24 hours (86400 seconds) and Chromium at 10 minutes (600 seconds). Chromium also specifies a default value of 5
seconds.
A value of -1 will disable caching, requiring a preflight OPTIONS check for all calls.
What is a recommended Access-Control-Max-Age value and how to choose it?
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
Firefox caps this at 24 hours (86400 seconds).
Chromium (prior to v76) caps at 10 minutes (600 seconds).
Chromium (starting in v76) caps at 2 hours (7200 seconds).
Chromium also specifies a default value of 5 seconds.
We use 86400 seconds.

How to reduce tag waiting time in selenium

I'm trying to click a specific link in the web page with specific text.
However, if the link is not present, it takes 1 minute before it prints out element is not found. How do I reduce this time for faster execution?
try{
if (!driver.findElements(By.xpath("//a[text()='specifictext']/#href")).isEmpty())
{
By loadMoreComment=By.linkText("specifictext");
driver.findElement(loadMoreComment).click();
}
}
catch (NoSuchElementException e)
{
logger.warn("Specific text not found");
}
That would only happen because of implicit waits. Look at below definition
Implicit Waits
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
So you should lower that implicit wait if you want an early failure
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
The above call before your code, will ensure the failure happens within 2 seconds
Use Implicit wait to reduce tag waiting time.
Implicit waits are used to provide a waiting time (say 30 seconds)
between each consecutive test steps across the entire test script or
program. Next step only executed when the 30 Seconds (or whatever time
is given is elapsed) after execution of previous step.
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

WebDriverWait timer resets between tests?

I have the following code:
// setting timeout to a FULL MINUTE
WebDriverWait wait = new WebDriverWait(driver, 60);
Actions action = new Actions(driver);
// First, click the usermenu
WebElement userMenu = wait.until(ExpectedConditions.elementToBeClickable(By.id("UserMenu")));
userMenu.click();
WebElement adminPortal = driver.findElement(By.id("AdminPortals"));
action.moveToElement(adminPortal);
action.perform();
// Wait for secondary menu to become available
WebElement portal = wait.until(ExpectedConditions.elementToBeClickable(By.id(portalId)));
portal.click();
Basically, "UserMenu" is a drop-down, and there's a hover-over expansion menu "AdminPortals". The above code simulates (in Selenium, the action of clicking on an item in the expanded menu.
The question I have is in relation to the timeout period. When does it start counting down? I assume it is when I use wait.until(). And I assume it stops counting once True is returned by ExpectedConditions? And, the real question is: If I use the same "wait" twice, as I have here, does the 60 seconds reset as the limit between each use, or does it restart counting where it stopped before?
So, if the first wait took 2 seconds, and the second wait took 3 seconds, will the timeout for the third call to wait.until() be 55 seconds, or reset to 60?
Yes, it starts counting down when you call the until method. When you instantiate a new WebDriverWait object and specify a timeout it sets up a clock, so each time you call the util method on that object it will continue to count down the same timer. It doesn't reset the timer each time it returns. If you want the timer to reset you will need to create new WebDriverWait objects.
This is really unclear in the documentation. I had to look at the code to figure out what was going on. The logic is actually inherited from the FluentWait class. Here's the source code link I looked at:
https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/support/ui/FluentWait.java
So, if the first wait took 2 seconds, and the second wait took 3 seconds, the timeout for the third call to wait.until() will be 55 seconds.

Selenium+PHPUnit: Set maximum waiting time in waitForElementPresent

I use Selenium and PHPUnit. In my testcases, I use
PHPUnit_Extensions_SeleniumTestCase::waitForElementPresent($xpath);
to wait for some time until element specified by $xpath becomes present. Is there any way to change the maximum time of waiting?
waitForElementPresent() takes two arguments. The first one is the locator and the other is Timeout in miliseconds.
Example :
waitForElementPresent("Your xpath","80000").
This will wait for the given xpath for 80 seconds.