Or do they only affect findElement? For example, if I want to test for an element that does not exist on the page, do I want to use findElement (which will be slow due to implicit waiting), or can I use findElements(..).size() == 0 (for example)?
Yes. Implicit wait is firm to the driver instance and as soon as you instantiate the driver it will apply to any findElement mechanism. Explicit wait is your best bet in terms of waiting for the element since explicit wait does not have influence on the entire driver instance.
Please note Implicit wait also has influence over explicit waits. Mixing them both together is never recommended. See this
I had the same question & found an answer in findElement(By by) documentation (in WebDriver.java).
/**
* Find the first {#link WebElement} using the given method.
* This method is affected by the 'implicit wait' times in force at the time of execution.
* The findElement(..) invocation will return a matching row, or try again repeatedly until
* the configured timeout is reached.
*
* findElement should not be used to look for non-present elements, use {#link #findElements(By)}
* and assert zero length response instead.
*
* #param by The locating mechanism
* #return The first matching element on the current page
* #throws NoSuchElementException If no matching elements are found
* #see org.openqa.selenium.By
* #see org.openqa.selenium.WebDriver.Timeouts
*/
WebElement findElement(By by);
in short:
findElement is affected by the 'implicit wait'
findElement should not be used to look for non-present elements
for non-present elements, use findElements
Related
I want to create an experiment in PsychoPy Builder that conditionally shows a second routine to participants based on their keyboard response.
In the task, I have a loop that first goes through a routine where participants have three options to respond ('left','right','down') and only if they select 'left', regardless of the correct answer, should they see a second routine that asks a follow-up question to respond to. The loop should then restart with routine 1 each time.
I've tried using bits of code in the "begin experiment" section as such:
if response.key=='left':
continueRoutine=True
elif response.key!='left':
continueRoutine=False
But here I get an error saying response.key is not defined.
Assuming your keyboard component is actually called response, the attribute you are looking for is called response.keys. It is pluralised as it returns a list rather than a single value. This is because it is capable of storing multiple keypresses. Even if you only specify a single response, it will still be returned as a list containing just that single response (e.g. ['left'] rather than 'left'). So you either need to extract just one element from that list (e.g. response.keys[0]) and test against that, or use a construction like if 'left' in response.keys to check inside the list.
Secondly, you don't need to have a check that assigns True to continueRoutine, as it defaults to being True at the beginning of a routine. So it is only setting it to False that results in any action. So you could simply do something like this:
if not 'left' in response.keys:
continueRoutine = False
Lastly, for PsychoPy-specific questions, you might get better support via the dedicated forum at https://discourse.psychopy.org as it allows for more to-and-fro discussion than the single question/answer structure here at SO.
Why we need queueSizeRejectionThreshold in Hystrix apart from maxQueueSize?
By definition, queueSizeRejectionThreshold <= maxQueueSize. But I am not getting why not to reject thread when maxQueueSize becomes full, why to introduce the term queueSizeRejectionThreshold?
The documentation explains the reason why you may need queueSizeRejectionThreshold:
This property exists because the maxQueueSize of a BlockingQueue cannot be dynamically changed and we want to allow you to dynamically change the queue size that affects rejections.
If you don't want to change the queue size dynamically (in run time) simply set maxQueueSize = queueSizeRejectionThreshold.
I'm sure this has already been asked somewhere but I can't seem to find it, so here it goes.
I am creating a program in C and using Doxygen to generate documentation. I am quite satisfied with the results, however the main page has no content. I would like to fill the main page with a list of all functions and structures used in the program in alphabetical order.
I do not know much about Doxygen, beyond the simple tutorial that I have used to get this far. It seems like a task that Doxygen would be able to do, but so far all I have found is instructions on how to create a custom main page.
Is it possible to use Doxygen to automatically generate a list of functions and structures on the main page?
Doxygen doesn't really offer a lot from the configuration point of view. You can use, together with Doxygen and doxyrest, a tool called Sphinx.
Basically, you'll be able to generate XML using Doxygen. Doxyrest is going to convert the XML output into .rst files, while Sphinx will work with the final result (it only handles .rst, that's why you'll need to use an intermediate tool like doxyrest).
Sphinx is going to generate beautiful HTML pages that are easy to read and, more important, to configure.
Information on how to combine these three tools and use them together can be found on this page: https://vovkos.github.io/doxyrest/manual/basic.html
A solution to your problem would be to group your functions using the \addtogroup Doxygen command (add all functions to the same group), and then, using Sphinx, select the newly created group page to be your index/landing page. This can be done by editing some lines in Sphinx's conf.py.
I was also looking for a more elegant way to see and search all functions.
Maybe the following trick will help you that i currently use:
If you use the #todo in your function headers,
then you will get in "Related Pages" a "Todo List" with all function names.
There you will get an alphabetical list with all functions with #todo.
You are also able to klick on the function name for better navigation.
Example/tip: If you view html output with web browser, you are able to search the todo list for function.
I recommend you to use #mainpage. This function changed the header of the main page and then after it you can use functions like #brief for a short information.
Use html tags to create sections, for me it works. Then in the new section with function #see you can go from the main page to functions or files. This is a working excample:
/**
* #mainpage WATCHDOG
* <hr/>
* #setion <b> File tree<b/>
* #brief Here you can see the main files which are used.
* #see io.c
* #see watchdog.c
* #see watchdog.h
* <p/><br/>
* <hr/>
* In this part we have few main functions used by the programm
* <p/><br/>
* #see watchdog_init_s();
* #see fpga_resetregs_init_s();
* #see watchdog_read(int add, unsigned int ws );
* #see watchdog_reset_io_write(WD * watchdog, unsigned int* data,unsigned int *ws );
* <hr/>
*/
I am trying to create automated test that involves an angularjs auto-complete.
Since Selenium webdriver is simply assigning values to fields, rather than typing, the drop-down does not populate upon playback.
Is there a way in selenium and/or PHPunit, to simulate actual physical typing (which initiates auto-complete to return suggestions)
You can do that with WebDriverElement::sendKeys:
/**
* Simulate typing into an element, which may set its value.
*
* #param mixed $value The data to be typed.
* #return WebDriverElement The current instance.
*/
public function sendKeys($value);
like this:
$driver->findElement(\WebDriverBy::id("email"))->sendKeys("user#example.com");
I simulate selecting from a dropdown by using a loop to send down arrows once every half second, similar to this pseudo-code :
loop {
sendKeys( Keys.DOWN );
sleep 0.5
}
You could do the same with sending single characters...
So I have seen this error show up, just sometimes, but it is not helpful in describing the actual error which has occured. Nor does it give any clues as to what might cause it to display.
Cannot use modParams with indexes that do not exist.
Can anyone explain more verbosly what this error means, what it relates to (such as a behaviour, component, controller, etc), the most common causes and how to fix it?
To kickstart the investigation, you can find the error here.
https://github.com/cakephp/cakephp/blob/master/lib/Cake/Utility/ObjectCollection.php#L128
Layman's Terms
CakePHP is being told to apply an array of parameters to a collection of objects, such that each particular object can modify the parameters sent on to the next object. There is an error in how CakePHP is being told to do this.
In Depth
Generically, this rises from the CakePHP event publication mechanism. Somewhere in your code is an instance of ObjectCollection, which is being triggered with certain parameters. That is, a method is being called on every object in that collection.
Each callback method is given parameters. Originally the parameters are passed into trigger(). In normal cases (where modParams is false), every callback gets the same parameters. But when modParams is not strictly false, the result of each callback overwrites the parameter indicated by modParams.
So if there are two objects in the collection, modParams is 1, and the params[1] is 'a' initially, then the callback is given the first object with params[1] == a. That callback returns 'b', so when the next callback is called, the second object gets params[1] == b.
The exception raises when the modParams value given does not exist in the originally given params. Eg, if modParams is 2 and params is array (0 => 'a', 1 => 'b'), you'll get this exception.
In your case
Specifically, debugging this has to be done at a low-level because it's a method on a generic class. The backtrace from the Exception should get you bubbled up to a trigger() call on a particular concrete class. That call is being given non-false modParams and a params that doesn't have the given modParams. It could be a code bug in a concrete class extending ObjectCollection, or it could simply be a generic message arising from a method not being given expected arguments.
Have you tried reading the documentation?
/*
* - `modParams` Allows each object the callback gets called on to modify the parameters to the next object.
* Setting modParams to an integer value will allow you to modify the parameter with that index.
* Any non-null value will modify the parameter index indicated.
* Defaults to false.
*/
You did not paste any code, so I guess your 3rd arg of the method contains something wrong.