PHPUnit selenium doesn't support sendKeys? - phpunit

I was writing test with sendKeys command at Selenium IDE that was fine. But when I was change to PHPUnit Selenium I got an error that was Method sendKeys not defined, so I want to know is PHPUnit-Selenium doesn't support or I need to add a method? If the answer is I need to add senKeys method if so let's me know how to add senKeys method.

I couldn't figure this one out either for a while... the trick is that it's not called sendKeys and you don't use {ENTER} in PHPUnit with Selenium. These are not the functions you are looking for!
Instead, click on the element you wish to type into and then use the keys function like so:
$this->byXpath('//*[#id="theOneToTypeIn"]')->click();
$this->keys('some keys to type'.Keys::ENTER);
Make sure that at the top of your page you include the Keys class as well:
use PHPUnit_Extensions_Selenium2TestCase_Keys as Keys;
The supported keys can be found here: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
I read that the SendKeys are supported the same was as in the JSON wire frame so I would imagine that the constants are the same names as they are in that link... but then I also imagined that all the function names would be the same and here we are.

Related

what is the use of first argument of createAsyncThunk?

I'm new in redux toolkit and I've managed state with redux toolkit lately. But the thing I don't know, what is usage of first argument of CreateAsyncThunk. I've read this article: https://redux-toolkit.js.org/api/createAsyncThunk and according to this, CreateAsyncThunk has two argument and first argument is named type :
A string that will be used to generate additional Redux action type constants, representing the lifecycle of an async request
Ok. But we never need to call or use this argument again, so why is important to name this argument? I tried adsfds insted of requestStatus after / and my project worked perfectly! I also understand it also works even without slash.
It seems it doesn't matter what you write as first argument, It always works! So what is the usage of the first argument?
In Redux, every action is identified by a unique type string. So createAsyncThunk creates three actions for you - in your case with the type strings "adsfds/pending", "adsfds/fulfilled" and "adsfds/rejected".
If you do not use "asdfds" in any other createAsyncThunk, that's a perfectly fine thing to do, but if you look at the Redux Devtools browser extension to see what is happening in your application, a string like that might make it very difficult to read.

How to reuse page_source in Appium driver queries

I have checkForKnownExceptionScreens() function to check for all the known popup windows.
The checkForKnownExceptionScreens() performs multiple queries using Appium webdriver on various id strings. For example, it invokes multiple driver.find_elements_by_id() with different ids, it also invokes driver.find_elements_by_class_name() with different class name etc.
This results in making multiple calls to the Appium server thus to the mobile device.
To make the function efficient, I want to get get the page source XML content through driver.page_source and use the XML content within my function.
Is there a way to achieve this task?
You would have to parse that xml to find if it really contains what you need.
Easier solution would be to create a list of elements on your view and iterate trough it to see if it contains your element.
Sample (java) code:
List<AndroidElement> elementsList = driver.findElements(By.xpath(".//*"));
for(AndroidElement element : elementsList){
// check if it's your element
}

How to adjust Capybara finders on a site using css-modules?

In our automated tests, a typical line in our code might look something like:
find('.edit-icon').click
We're on our way to using css-modules in our project and I've been warned that class names may change dramatically. A pretty zany example is this site that uses emojis in its class names (when you inspect the page):
css modules by Glenn Maddern
How might I best prepare for a change this drastic? I imagine many of our specs breaking, but I am a little worried about being unable to write tests at all with this new technology in our project.
Using custom capybara selectors you can abstract away from the actual css query being done and move it to one location. In your comments you mentioned the need to change to a class attribute that begins with a passed in value.
Capybara.add_selector(:class_starts_with) do
css { |locator| "[class^=\"#{locator}\"]"
end
would do that and then can be called as
find(:class_starts_with, 'something')
or if you set Capybara.default_selector = :class_starts_with it would just be
find('something')
Rather than changing default_selector another option would be to just define a helper method like find_by_class_start or something that just calls find with :class_starts_with passed (how Capybara's #find_field, etc work).
Also note the custom selector above would only really work if only one class name was set, if multiple are expected you could change the selector to "[class^=\"#{locator}\"], [class*=\" #{locator}\"]"

How do I find which messages an object understands?

In Pharo, I know that integers understand the message to:. The workspace offers suggestions:
But if I inspect an integer from the workspace, it doesn't mention to::
Searching for SmallInteger doesn't show anything in the system browser either:
How do I discover which messages I can send to objects? Ideally I'd like to see their source code too.
Revisiting your question I noticed that, in your last screenshot, you did not search for the class SmallInteger but for a package named SmallInteger. This Package does not exist.
But you probably wanted to search for the class SmallInteger. This is done by the keyboard shortcut Cmd-F Cmd-C (Alt-F Alt-C on Linux) or by selecting Find Class… in the context menu of the class panel of the Nautilus system browser. This lets you browse the methods implemented in SmallInteger. If you work up your way through the superclasses you can have a look at all messages understood by an instance of SmallInteger.
Each class understands the message allSelectors.
allSelectors answers a set of all the message selectors that instances of the receiver can understand. This includes all messages selectors in the method dictionary of the receiver and in the method dictionaries of it’s superclasses.
So try and print or better, inspect:
1 class allSelectors.
Also, you can just type the name of the class wherever you want, select it, then press command+B (browse). That'll bring up a browser on said class.

How can a Tridion command extension find out the command it extends?

Tridion's user interface allows you to extend specific commands, which is a great way to modify the behavior of certain existing commands. In the configuration file of the editor this is done with a section like this:
<ext:commands>
<ext:command name="TextUnderline" extendingcommand="MyTextUnderline"/>
<ext:command name="TextStrikethrough" extendingcommand="MyTextStrikethrough"/>
I am working on a generic command extension class that can be used to modify the behavior of a number of commands:
<ext:commands>
<ext:command name="TextUnderline" extendingcommand="MyCommandExtension"/>
<ext:command name="TextStrikethrough" extendingcommand="MyCommandExtension"/>
So in this second configuration fragment, we have the same MyCommandExtension extending both TextUnderline and TextStrikethrough.
But now in the JavaScript for my MyCommandExtension, how can I determine which command was originally fired?
MyCommandExtension.prototype.isAvailable = function (selection, pipeline) {
...
console.log(this.properties.name);
...
};
In this scenario the this.properties.name will be logged as a less-than-useful-but-completely-correct:
"DisabledCommand"
I suspect that the information is available somewhere in the pipeline parameter, but haven't found it yet.
How can I find out the original command from MyCommandExtension?
Short answer: I couldn't.
I had to do something similar, and ended up having to extend various commands and set the "current" command as part of my "_execute" call (so I would now call _execute(selection, pipeline, originalCommand) for my command.
N
You cannot find out what the original command is. The assumption is that an extending command is specific to the command it extends and so would know which one it is extending. When creating generic extensions that work on different commands, I can see how it might be useful to know what the configuration would be.
Maybe you could add this as an Enhancement Request?
To work around it for now, you could create a base command with your logic - which takes the name of the command that it extends as a parameter. And then create specific classes for each command you which to extend, which just call the base command and pass in the name.
To put it differently, create a BaseExtendingCommand with all of the required methods - and then both a TextUnderlineExtendingCommand and TextStrikethroughExtendingCommand which call the methods on BaseExtendingCommand (and pass in "TextUnderline" and "TextStrikethrough", respectively, as arguments)

Resources