I can't input date in from on my web test using Laravel Dusk - laravel-dusk

I attempt write code for test input date on form. My from use input date form w3s.
public function testAddCustomer()
{
$this->browse(function (browser $browser) {
$browser->clickLink('เพิ่มลูกค้า')
->pause(500)
->assertPathIs('/customer/create')
->assertSee('ลงทะเบียนลูกค้า')
.
.
.
->select('product_id', '1500ml')
->type('product_date', '17082017')
->pause(500)
//->press('บันทึก')
;
});
}
I can't input date on test Laravel Dusk.

Have you tried using "keys"?
->keys('#date', '20171018')
Changing #date to your input selector, as is suggested here:
https://github.com/laravel/dusk/issues/104

Related

Gatling use session.set and feed simultaneously

If I use .get("/***/quotes-${endPoint}/quotes?source=rtbp&userid=test&symbol=${pTypeSymbol}${authM}${pEqSymbol}") then ${pEqSymbol} work but
${pTypeSymbol} will be ${pEqSymbol} it's incorrect example of get it should be in code below
val getApiKeyScenario = scenario("getApiKey")
.feed(getApiKeyData)
.feed(pEqSymbolFeed)
.feed(pOptionSymbol)
.feed(pOtherSymbol)
.exec(session => session
.set("endPoint", "v1")
.set("pTypeSymbol", "${pEqSymbol}")
.set("authM", "&apikey=***********"))
.exec(http("getApiKeyRequest")
.get("/******/quotes-${endPoint}/quotes?source=rtbp&userid=test&symbol=${pTypeSymbol}${authM}")
.check(status.is(200))
.check(checkIf(doLogResponse) {
bodyString.saveAs("pResponse")
})
)
.doIf(doLogResponse) {
logResponse()
}
If I try .set("pTypeSymbol", pEqSymbolFeed.readRecords.head("pEqSymbol")) will be loop
If I try .set("pTypeSymbol", s"${pEqSymbol.isDefined}") not found: value pEqSymbol
If I try s"${pEqSymbol}" not found: value pEqSymbol
I logs now is GET *******/quotes-v1/quotes?source=rtbp&userid=test&symbol=${pEqSymbol}&apikey=******
But should be GET *******/quotes-v1/quotes?source=rtbp&userid=test&symbol="Here my value from feed"&apikey=******
Please read the official documentation:
This Expression Language only works on String values being passed to Gatling DSL methods. Such Strings are parsed only once, when the Gatling simulation is being instantiated.
For example queryParam("latitude", session => "${latitude}") wouldn’t work because the parameter is not a String, but a function that returns a String.
In your example, you don't need to copy pEqSymbol into pTypeSymbol, you can directly write:
.exec(session => session
.set("endPoint", "v1")
.set("authM", "&apikey=***********"))
.exec(http("getApiKeyRequest")
.get("/******/quotes-${endPoint}/quotes?source=rtbp&userid=test&symbol=${pEqSymbol}${authM}")
)
)
But if you insist on copying, you have to use the Session API:
.set("pTypeSymbol", session("pEqSymbol").as[String])

Generate dynamic tests based on a parameter in Nightwatch

I'm using NightwatchJS to automate the test on our reporting website.
This is my actual code:
module.exports = {
'#tags': ['Report 1','base','full'],
'Report 1' : function (browser) {
checkAnalisi(browser, 'report1', 1, 2015, '767.507')
}
};
function checkAnalisi(browser, nomeAnalisi, scheda, year, risultatoAtteso){
return browser
.url('https://example.com/Wizard?analisi=' + nomeAnalisi)
.waitForElementVisible('body', 5000)
.selectScheda(scheda-1) //Seleziona la scheda (0-based)
.selectPromptValue('Year', year)
.selectRappresentazione('Table')
.waitForElementVisible('table', 5000, true)
.assert.containsText('table tr:last-child td:last-child', risultatoAtteso)
.end();
}
I made some helper commands to select different things in the page:
.selectScheda(scheda-1)
.selectPromptValue('Year', year)
.selectRappresentazione('Table')
selectPromptValue wants a prompt name and the value to set it in the page.
For now the function only sets the year parameter but in my reports I also have different parameters.
What I want to do is to pass an object to the checkAnalisi function to dynamically generate test. For example if I want to set different prompt values I want to pass something like [['Year', 2015],['Another prompt','another value']] and the checkAnalisi function should add 2 .selectPromptValue steps with the respective values.
Is it possible to cycle an input array in my function to add more steps?
Actually I was able to solve this easily directly in my selectPromptValue custom command.
I simply added the new parameter to the checkAnalisi function like this (promptValues is the new parameter):
function checkAnalisi(browser, nomeAnalisi, scheda, promptValues, risultatoAtteso){
return browser
.url('https://example.com/Wizard?analisi=' + nomeAnalisi)
.waitForElementVisible('body', 5000)
.selectScheda(scheda-1) //Seleziona la scheda (0-based)
.selectPromptValue(promptValues)
.selectRappresentazione('Table')
.waitForElementVisible('table', 5000, true)
.assert.containsText('table tr:last-child td:last-child', risultatoAtteso)
.end();
}
I then modified the selectPromptValue.js custom command like this:
exports.command = function(v) {
for(var i=0; i<v.length; i++){
this.execute('$("#"+$("label:visible:contains(\'' + v[i][0] + '\')").attr("for")).val("' + v[i][1] + '")');
}
return this;
};

yii2 fixtures doesn't work properly

I have a problem with fixtures in yii2 , I just created all required file according to this document but it's not working.
let me explain , I have a module called Authyii and inside this module I have a model named User .
this is my directory structure :
my fixture file is like this :
namespace app\modules\Authyii\tests\fixtures;
use app\modules\Authyii\models;
use yii\test\ActiveFixture;
use yii\test\Fixture;
class UserFixture extends ActiveFixture
{
public $modelClass = 'app\modules\Aythyii\models\User';
public $tableName = 'authyii_user';
}
this is my command line :
but after I type 'yes' and command line says :
but when I check my database there is not new record inside authyii_user tables .
what I missed ?
File User.php id data dir must have table name authyii_user.php. In framework source code in file ActiveFixture.php line with code:
$dataFile = dirname($class->getFileName()) . '/data/'
. $this->getTableSchema()->fullName . '.php';
Best regards.
There is method getFixturesConfig() in \vendor\yiisoft\yii2\console\controllers\FixtureController.php
private function getFixturesConfig($fixtures)
{
$config = [];
foreach ($fixtures as $fixture) {
$isNamespaced = (strpos($fixture, '\\') !== false);
$fullClassName = $isNamespaced ? $fixture . 'Fixture' : $this->namespace . '\\' . $fixture . 'Fixture';
if (class_exists($fullClassName)) { // <<< I think you lose your UserFixture here
$config[] = $fullClassName;
}
}
return $config;
}
You should check what $fullClassName Yii expects it to be (for example logging or echoing it) and tweak your UserFixture's namespace accordingly.

Rename screenshots taken on failure in PHPUnit Selenium

PHPUnit has an option to take a screenshot upon a Selenium test case failure. However, the screenshot filename generated is a hash of something - I don't know what exactly. While the test result report allows me to match a particular failed test case with a screenshot filename, this is troublesome to use.
If I could rename the screenshot to use the message from the failed assert as well as a timestamp for instance, it makes the screenshots much easier to cross-reference. Is there any way to rename the generated screenshot filename at all?
You could try something like this (it's works with selenium2):
protected function tearDown() {
$status = $this->getStatus();
if ($status == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR || $status == \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
$file_name = sys_get_temp_dir() . '/' . get_class($this) . ':' . $this->getName() . '_' . date('Y-m-d_H:i:s') . '.png';
file_put_contents($file_name, $this->currentScreenshot());
}
}
Also uncheck
protected $captureScreenshotOnFailure = FALSE;
I ended up using a modified version of #sectus' answer:
public function onNotSuccessfulTest(Exception $e) {
$file_name = '/' . date('Y-m-d_H-i-s') . ' ' . $this->getName() . '.png';
file_put_contents($this->screenshotPath . $file_name, base64_decode($this->captureEntirePageScreenshotToString()));
parent::onNotSuccessfulTest($e);
}
Although the conditional check in tearDown() works fine, based on Extending phpunit error message, I decided to go with onNotSuccessfulTest() as it seemed cleaner.
The filename could not accept colons :, or I would get an error message from file_get_contents: failed to open stream: Protocol error
The function currentScreenshot also did not exist, so I ended up taking the screenshot in a different way according to http://www.devinzuczek.com/2011/08/taking-a-screenshot-with-phpunit-and-selenium-rc/.
Another method I played around with, as I still wanted to use $this->screenshotUrl and $this->screenshotPath for convenient configuration:
I overwrote takeScreenshot from https://github.com/sebastianbergmann/phpunit-selenium/blob/master/PHPUnit/Extensions/SeleniumTestCase.php
protected function takeScreenshot() {
if (!empty($this->screenshotPath) &&
!empty($this->screenshotUrl)) {
$file_name = '/' . date('Y-m-d_H-i-s') . ' ' . $this->getName() . '.png';
file_put_contents($this->screenshotPath . $file_name, base64_decode($this->captureEntirePageScreenshotToString()));
return 'Screenshot: ' . $this->screenshotUrl . '/' . $file_name . ".png\n";
} else {
return '';
}
}

Store.reload() ->How to Query by lastParam in ExtJs4

I have a Grid.
Get Data Code
Code:
var myParam = {
typeId : 1,
xxxx : 'xxxx' //some else
}
grid.store.load(myParam);
When to do something such as time renovate
Code:
grid.store.reload();
But this lost param.
In ExtJs3 have a Config of LastParam .
How to do in Extjs4.
thanks.
use the proxy's extraParams config.
grid.store.getProxy().extraParams = myParam;
grid.store.load();
grid.store.reload();
This way the params will be sent until you modify the extra param again with code.