friends.
I need some help, please.
I'm trying to disable the timeout alert in an instruction and pass a timeout parameter, however it's not working:
Driver.FindElementById("ctl01_lnkCharacter", 5000, False).Click
I've already tried the way below too, the same situation happens
Driver.FindElementById("ctl01_lnkCharacter", timeout:=5000, raise:=False).Click
The timeout parameters (5000) and raise for not to alert in case of timeout (False) are ignored. It uses the default timeout parameter, or if it has passed the parameter explicitly before, this value is assumed.
I tested passing the different parameter above to test:
Driver.Timeouts.PageLoad = 1500
Driver.FindElementById("ctl01_lnkCharacter", 5000, False).Click
In this case, the timeout is considered to be 1500 and not 5000 (I did this just to test) and the "False" is ignored, if it reaches the timeout there is an error alert.
In the instruction below it works perfectly:
Driver.Get url, 2000, False
It respects the timeout (2000) and if it is reached there is no error alert.
The problem is only in the .click statement
When I use .FindElementById(...).click What is passed in the parameters as timeout and raise are ignored.
.FindElementById("ctl01_lnkCharacter", TIMEOUT, RAISE).click
I thought I'd try to use a variable, maybe it could works, for example
var = Driver.FindElementById("ctl01_lnkCharacter", 5000, False)
var.click
But I couldn't do that, the variable is not accepted, does anyone have any idea of a solution for this case?
EDIT:
I Forgot to say, the problem is not the timeout, i can pass the timeout before, explicitly.
The problem is the raise, I need to disable the error alert in case of timeout. Is there any other way to disable the error alert in case of timeout (without using On Error Resume Next, I can't use this )
EDIT2:
Sorry, I forgot to say too. The button is clicked correctly, the page opens correctly, but sometimes some images are loaded and I don't need to wait for the loading time and it takes a long time and this time varies a lot, while these images are loading it hits the timeout and generates the error.
That's why I need to disable the timeout error alert (raise parameter False).
Related
I am performing an until loop in logic app. In this loop I'm using a delay function to do the next loop. But if we manage the delay unit to hour, the loop will end in the second time. That means the loop will only executed twice!(Escalation variable is 72 and LoopCounter increments from 0) I want to know if it is a bug from logic app or I did some wrong settings.
Please see the settings as below.
This issue seems to be with 'Until Loop' timeout. To resolve this you can try the following ways:
It looks like this is due to a bug in the way we evaluate the timeout limit value in the until scope.
Remove the triggerBody{} from the limit.timeout property – i.e. make a it a static value
If you really need to make the timeout computation dependent on the payload of the trigger request, you may want to add the “triggerBody()” into the “expression” property of the “until” (this is because we parse the expression when loading dependencies before the action is run)
For example:
You can refer to Configure Logic App 'Until Loop' timeout dynamically, Iteration in Logic Apps terminates prematurely, Until Loop Dynamic Count Limit and Add the Delay-until action
I'm writing a rails app which fetches text from an HTML page using Watir and Chrome Headless. All good so far!
The problem starts when I request a page which has a long load time to completely load all elements despite the fact that I don't need them.
Current code I use:
browser = Watir::Browser.new :chrome, headless: true
browser.goto(url)
The .goto function call, however, blocks until ALL elements have loaded. That's not really what I need - what I need is for goto to just start fetching the page, then continue running code since I really just want to wait until the text I need is present, then fetch it.
Any ideas?
Goto will not leave the control until 60 seconds, If page load time exceeds 60 seconds, then it would throw the error. And also Watir.default_timeout has nothing to do with Goto's page loading. You need to set the timings for page_load which you can do by directly calling selenium driver as I have done below because Watir hasn't offered any systax for that
Write the below code, you could achieve what you want
begin
b.driver.manage.timeouts.page_load=5
b=Watir::Browser.new
b.goto(url)
rescue #I have written the rescue block here because goto will the error for you If page is not loaded within a given time
end
AND THEN you can write your rest of the code here, for an example,
puts b.span(text: 'something').text
What happens here is, goto will be block the execution of the code followed by goto for 5 seconds, and then it would fall into the rescue block, so program would continue to execute next line as you expected.
With the new w3c webdriver specification, you can set the page load strategy to 'none.' https://w3c.github.io/webdriver/webdriver-spec.html#navigation
Only Firefox and IE might have this implemented already.
I know that there are several questions related to implementation of waiting and timeouts in Watir, however I have not found an answer to my problem (which must be common). I use Watir-webdriver for testing of a page that due to AJAX implementation loads portion-by-portion for very long time (more than 5 min). I need to be able just to sample this page for a limited time (20-40 sec) and to be able to analyze the information that is loaded during this short time. However, as I know, there is no straightforward direct mechanism to tell Watir::Browser to stop. I can use the Timeout, but although my script gets the control after rescue, it is impossible to interrogate the browser and verify the information that it is able to received during the timeout window. All I can do at this point is to kill the process and restart the browser as discussed here: Make headless browser stop loading page and elsewhere.
The code below illustrates my situation. In this example I have a global timeout (30 sec) and a local timeout (15 sec) used for reading the page. It never gets to b.text call; the script just outputs the first exception after 15 sec and then it keeps waiting for the browser to be released and after the global timeout of 30 sec prints the second exception message.
Time out. Got into exception branch
Dropped to bottom rescue.
The end.
I also tried to send an 'escape' key to the browser, but any communication with it while it is in the goto method is impossible. Any tips and suggestions will be appreciated!
require 'watir-webdriver'
require 'timeout'
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 30 # Set the global timeout
b = Watir::Browser.new :chrome, :http_client => client
my_url = '...here is my address...'
begin
begin
Timeout::timeout(15) { b.goto my_url } # Access the page with local timeout
b.close # if all is unbelievably good and the page is loaded
rescue Exception => e
puts 'Time out. Got into exception branch'
if b.text.include? 'my_text' # NEVER GETS HERE
puts 'Yes, I see the text!'
else
puts 'I do not see the text.'
end
end
rescue Exception => e
puts 'Dropped to bottom rescue.'
end
puts 'The end.'
Watir relies on Selenium WebDriver to handle calls to the browser. At this time all browsers require that the document.readyState of the current frame return "complete" before returning control to your code.
A recent update to the webdriver specification appears to allow for the possibility of a browser driver implementing a page loading strategy that is not blocking, but it is not a requirement and is not supported at this time.
https://w3c.github.io/webdriver/webdriver-spec.html#the-page-load-strategy
I am running ServiceStack 3.97 and just added the RequestLogger plugin - amazing that it is built-in, just what I needed. The worrisome thing I noticed once I tried it is that it says all the previous GET requests have "is running = true".
For example, I issued a few requests in a browser tab (pressing F5 a few times, and closed tab) and can see them show up here /api/requestlogs. In the items column, the elapsed time keeps ticking each time I refresh and is running is always true.
This is very scary as it appears to be saying that the requests remain open. If so, it could be related to an unknown error I get over time whereby SS is unable to return an Open connection.
Here is a sample of the items field:
_request Duration Stopwatch
is Running true
elapsed PT8M31.5460178S
elapsed Milliseconds 511546
elapsed Ticks 1395611107
Any suggestions or ideas as to why this is happening and/or how to dig deeper? What would keep GETs open?
The RequestLogger takes a 'snapshot' which includes a dump of the Request.Items dictionary (which contains a Stopwatch) into a rolling log of DTO's, but this doesn't keep the request 'open' as you might think, so there's no need for concern.
I've worked with the .Exist method quite a bit, but I recently moved to a new project (now using a WPF application) with QTP 11 (whereas previously I had QTP 10).
Now I'd like to check that a message does not exist by using object.Exist(2). Weirdly, I only get a result after ~23 seconds, instead of the 2 seconds I was expecting.
How does the timeout work? In previous projects, using object.Exist(2) would wait 2 seconds before determining that the object didn't exist. The QTP help file also says it should only wait for 2 seconds (the specified timeout parameter).
Now, it seems as though it's waiting for the Timeout Parameter (2 seconds) AND Object Synchronization Timeout (20 seconds).
Also, Smart Identification is disabled, so it shouldn't be waiting for that. Highlighting the object using the Object Repository instantly says the object doesn't exist.
Has the timeout behavior changed between QTP v10 and v11?
Why does it take so long to say an object doesn't exist?
The Exist method does not work for the last object only.
It works hierarchically - which means this method checks each parent object before checking the last one.
The timeout only works for the last object.
if you want to receive the answer immediately, I suggest you use the following code-
if WPFWindow("x").Exist(0) Then
if WPFWindow("x").WPFButton("y").Exist(0) Then
'action
End if
End if
Make sure you don't have "Smart Identification" enabled for the test object in the Object Repository. That can get in the way.
The additional time that you're encountering is the default timeout setting, which is set to 20 seconds by default. Any Wait or Exist timers will stack on top of the default timeout.
It can be changed in the test settings:
Test Settings > Run > Object synchronization timeout - set in seconds
or in the vbscript:
Setting("DefaultTimeout") = 4000 'set in milliseconds
Using DefaultTimeout function at the beginning of the driver script would be sufficient .
Setting("DefaultTimeout") = 10000 'set in milliseconds
If any object exceeds the timeout limit of 10 seconds as mentioned above then the object will fail to get captured and Run Results will show a failure
I would recommend going by with just the default timeout. Using .Exist(x) will use the mentioned time for each child.