I am using action sequences in protractor while running my spec i am facing this issue can anyone help why this is happening and how to solve it.
Below is my spec code:
describe("Actions demo", function(){
it(" Open website ",function(){
browser.get("http://posse.com/");
element(by.model("userInputQuery")).sendKeys("river");
browser.actions().mouseMove (element(by.model("locationQuery")))
.sendKeys("London").perform()
browser.actions.sendkeys(protractor.key.ARROW_DOWN);
browser.actions.sendkeys(protractor.key.ENTER).perform();
})
})
You should use protractor.Key.ARROW_DOWN instead of protractor.key.ARROW_DOWN.
You are using key with lowercase instead of Key with uppercase.
It should also be browser.actions().sendKeys(), actions() with parenthesis.
In addition to Silvan response, remember to use .perform() at the end every usage of .actions() otherwise it will not work.
Related
I'm using a Sentinel policy inside a Terraform Cloud workspace. My policy is rather simple:
import "tfplan/v2" as tfplan
allBDs = tfplan.find_resources("aci_bridge_domain")
violatingBDs = tfplan.filter_attribute_does_not_match_regex(allBDs,
"description", "^demo(.+)", true)
main = rule {
length(violatingBDs["messages"]) is 0
}
Unfortunately, it fails when invoked with this message:
An error occurred: 1 error occurred:
* ./allowed-terraform-version.sentinel:3:10: key "find_resources" doesn't support function calls
The documentation and source for find_resources (doc) expects a string, yet the Sentinel interpreter seems to think I'm invoking a method of tfplan? It's quite unclear why that is, and the documentation doesn't really help.
Any ideas?
OK I found the issue. If I paste the code for find_resources and its dependencies (to_string, evaluate_attribute) then everything works as expected.
So I have a simple import problem and need to figure out how to properly import https://raw.githubusercontent.com/hashicorp/terraform-guides/master/governance/third-generation/common-functions/tfplan-functions/tfplan-functions.sentinel
Hellow there! I am using the wdio/cli so I created the wdio.conf.js with this command, then I start doing the test. But the issues is when have more than one test in a single or multiple test files.
In the test file I have something like this:
beforeEach(async function() {
$('~home').waitForDisplayed(81000, false);
});
Where home tag is a tag in the first view when the app runs in first screen. And appear this error:
element ("~home") still not displayed after 10000ms
So need to do kind of driver.resetApp()/ But dont know how to do it, what import do I need to do etc.
Did you try resetApp? You can't user driver as "main object" - Everything is under browser variable. Try this
//async
await browser.resetApp();
//sync
browser.resetApp();
Check Appium doc + wdio documentation.
I have several React tests using Jest and fetch-mock, each one of them doing some get operations, so what I initially did was:
beforeAll(){
fetchMock.get(`*`, JSON.stringify(CORRECTRESPONSE));
}
However, in some tests I need to return wrong data as answer, something like:
test('Wrong get answer', ()=> {
fetchMock.get('*', JSON.stringify(WRONGRESPONSE), {overwriteRoutes: true});
}));
So, since I need to reset the response for the following tests (and so return CORRECTRESPONSE, I came up with this solution:
beforeEach(){
fetchMock.get(`*`, JSON.stringify(CORRECTRESPONSE));
}
afterEach(fetchMock.restore);
Is there anyway better to do this?
I don't understand why the previous answer (https://stackoverflow.com/a/49778196/689944) was set as correct. Cleanup up after tests by afterEach(fetchMock.restore) is a very good way.
That's also what is described in the fetch-mock documentation: http://www.wheresrhys.co.uk/fetch-mock/#api-lifecyclerestore_reset
According to the docs this should do it
beforeEach(() => {
fetch.resetMocks()
})
I've been writing a suite of tests in Protractor, and am almost finished. I'm having difficulty figuring out how to do something fairly common though. I want to be able to check if a textbox contains a value, and if so, exit the testcase with a failure. (If the textbox contains a value, I know there's no chance the test case can pass anyway)
I'm currently trying something like this:
tasksPage.generalInformationDateOfBirthTextbox.getAttribute('value').then(function(attr){
//attr contains the correct value in the textbox here but how do I return it to parent scope so I can exit the test case?
console.log("attr length is " + attr.length);
expect(attr.length).toBe(0);
},function(err){
console.log("An error was caught while evaluating Date of Birth text value: " + err);
});
The expect statement fails as I'd expect it to, but the testcase keeps going, which seems to be the intended behavior of expect. So I tried returning a true/false from within the 'then' block, but I can't seem to figure out how to return that value to the parent scope to make a determination on. In other words, if I change the above to:
var trueFalse = tasksPage.generalInformationDateOfBirthTextbox.getAttribute('value').then(function(attr){
if(attr === ""){
return true;
}else{
return false;
}
},function(err){
console.log("An error was caught while evaluating Date of Birth text value: " + err);
});
//This is the 'it' block's scope
if(trueFalse == true){
return;
}
I know my inexperience with promises is probably to blame for this trouble. Basically, I just want a way of saying, 'if such and such textbox contains text, stop the test case with a failure'.
Thanks,
This is not a protractor issue, it is a testing framework issue (jasmine, mocha etc).
Though, there was an issue on protractor's issue tracker:
--fail-fast CLI option
which was closed with a reference to an opened issue in jasmine issue tracker:
Feature Request - fail-fast option
While this is not implemented, there is a workaround (originally mentioned here):
jasmine-bail-fast package
After installing the module with npm, when you want your test to fail and exit, add:
jasmine.getEnv().bailFast();
(don't forget to load the dependency require('jasmine-bail-fast');)
Also see:
Does jasmine-node offer any type of "fail fast" option?
The issue with the code above is that you are trying to compare a 'Promise' and a 'value'.
trueFalse.then(function(value)
{
if(value)
....
});
OR compare it via an expect statement. Something like expect(trueFalse).toBe(false);
I am using CakePHP 2.1.2 with PHP 5.3.5 and a plugin called 'Cakemenu' which normally works fine. The plugin stores menus in a db table with the menu link stored as text like
array('plugin'=>null,'controller'=>'assets','action'=>'index');
The helper in the plugin gets those values, then executes this code to convert that text to an array:
//Try to evaluate the link (if starts with array)
if (eregi('^array', $value['Menu']['link'])) {
$code = "\$parse = " . $value['Menu']['link'] . ";";
$result = eval($code);
if (is_array($parse)) {
$value['Menu']['link'] = $parse;
}
}
Everything works fine unless CakePHP is handling an error. For example if I mistype the name of a controller in the browser I should get a menu and then the missing controller message. Instead I get a page full "Parse error: syntax error, unexpected $end in..." messages pointing to the line with the eval statement. If I printout the variable that is getting eval'ed I see that it has been (incorrectly) encoded with Html entities when it normally does not.
Good string to be eval'ed:
$parse = array('plugin'=>null,'controller'=>'assets','action'=>'index');
Bad string to be eval'ed:
$parse = array('plugin'=>null,'controller'=>'Parts','action'=>'add');
To temporarily fix the problem I added two statements to just replace the offending characters
$value['Menu']['link'] = str_replace( ''','\'',$value['Menu']['link']);
$value['Menu']['link'] = str_replace( '>','>',$value['Menu']['link']);
and everything works great again. Some other pieces of information that might be helpful is that the array of data used to generate the menu is read during the beforeFilter of the app and saved in a view variable and then the menu is generated as an element in the view.
I'm thinking that the error causes CakePHP (or PHP) to skip some loading or configuration process and that causes the string to be mishandled. Any help would be appreciated, thanks
Your beforeFilter() method won't be executed on error pages. You'll have to handle your errors yourself and manually call beforeFilter(). I wrote a blog post on how to use custom error pages - pay close attention to the Controller Callbacks section.