TestCafe oncePerFixture Error when running - testing

I am trying to use oncePerFixture feature in TestCafe and get an error:
“TypeError: Cannot read property “testRun” of undefined.
I cannot figute out what is the problem?

I suppose that the problem is that you forgot to pass the t argument to the cleanDB function call inside the afterEach hook. If this does not help, please share your full example, as it's difficult to determine the cause of the issue without your full code.

Related

Detox not taking passed in environment variables

I am setting up testing environments on a react native app. Recently, my build commands have stopped including the environment variables that I pass into them.
EMAIL=testemail#test.com PASSWORD=testpassword xcodebuild....
When the app runs, process.env.EMAIL returns undefined and if I log the process.env object the EMAIL, PASSWORD, or any other variable provided in the command line is not listed.
UPDATE: This really seems to be an issue with detox/metro. This is where the passed-in environment variables should be received as is outlined in Detox's docs regarding mocking, which is also broken now.
Any ideas on what I changed that broke this functionality?
You can't store variables in .env file and access them using process.env directly in react native.
To achieve this you need to integrate react-native-config library.
I figured it out. I recently modified my bash script to read the variable values, and have them then passed in on the build call. Turns out, those need to be passed in when I call the script itself. So I solved the issue by nesting the script inside of another that reads the variables and then passes them in appropriately.
Any explanation as to why this script nesting works and not a single script would definitely be appreciated.

I get "t.openWindow is not a function" errors when I use TestCafe Window Management methods

The process for writing multiple windows tests described in TestCafe documentation seems pretty straightforward:
await t.openWindow('https://url.com/addnewproperty')
or even
const initialWindow = await t.getCurrentWindow()
should do it. However, every time I use any of the Window Management methods I get the errors:
TypeError: t.openWindow is not a function and cannot do anything about it.
Does anyone know what am I doing wrong and how to solve the issue?
TestCafe version 1.9.4
The problem was in different versions of Test Cafe used between main codebase and one of the underlying packages. Alex Kamaev answer was a correct one

Syntax error handling in dojo 18n resource file

require(["dojo/i18n!myapp/nls/extTools_i18nStrings"],function(extTools_i18nStrings){
// Do something with the loaded file
});
If the resource file (extTools_i18nStrings) has syntax error, it will be shown in dojo.js. How can I handle it in my code?
Try catch block did not work.
Thanks in advance.
Error: Script error .............dojo.js:15
The quick answer is you don't want to. The right thing to do is fix the bundle. This is the same as having errors in your application code, and you would not expect the code to 'handle' that.
But since i18n is an AMD plugin running as part of the loader (which is why you can't try/catch it), the error might be reported through the AMD micro event API, and you could use that to show a better error. I'm not sure how you 'handle' this syntax error other than showing an error.
If you can't control the quality of the bundles via some part of your development or build process you'd have to invent your own alternative to dojo/i18n and you probably don't want to go down that route for all of your bundles.

Selenium WebDriverException missing ) after argument list

js.executeScript("document.querySelector('input[name='password']');");
This line is throwing the following Exception in thread:
"main" org.openqa.selenium.WebDriverException: missing ) after argument list
Try the following code.
js.executeScript("document.querySelector('input[name=\'password\']')");
Try
js.executeScript("document.querySelector('input[name='password']')");
Let me know if this Answers your Question.
You can try one of the following
js.executeScript("document.querySelector(\'input[name=\'password\']\');");
js.executeScript("document.querySelector(\"input[name='password']\");");
Although in your comments you added this line
js.executeScript("document.querySelector('input[name=\'pas‌​‌​sword\']').value='ga‌​‌​mb'");
Which wouldn't work because if you look at .value you'll need to escape your .value setting as well more than likely.
Given that I don't have access to your site or your code, I would suggest that you test to make sure your javascript is valid for your page. One way to do so would be to take the javascript itself (everything insdie the .executeScript) and run it through your browsers dev tools console or script execution window.
If the value sets using the browsers dev tools, great...issue is with selenium. If the value does not set using browser dev tools...you'll need to refactor your javascript as the problem is likely not with selenium, rather your JS selector more than likely.
Although, the following, from your comment, works...you may not need to execute it via javascript.
driver.findElement(By.cssSelector("input[name='password']"‌​‌​)).sendKeys("gamb"‌​);

how to use Selenium::WebDriver::Element#attribute('value')

I have been getting
Selenium::WebDriver::Element#value is deprecated, please use Selenium::WebDriver::Element#attribute('value') warning.
I am getting this warning message only for
page.find(:xpath, "//select").value.should == "general".
Can any one tell me how to use attribute('value') instead?
I suspect you use capybara?
Got the same message myself, but capybara currently still accesses the value directly as seen in https://github.com/jnicklas/capybara/blob/master/lib/capybara/selenium/node.rb#L16
I will send them a fix. Should be done in future versions hopefully