cucumber webdriverio datatable - cucumberjs

FeatureFile
Feature: Shopper can add an item to their Grocery List
#kk
Scenario: Mutate multiple User Skills at the same time
Then If I click the row "Summary" then I should the following nested information`
| Tax | 11.50 |
| Gratuity | 4.50 |
| Total | 26.59 |
StepDefininition File
Then(/^If I click the row "([^"]*)" then I should the following nested information$/, function (rowName, data){
cconsole.log("rowName-----"+rowName)
console.log("data-----"+data)
data = dataTable.raw();
console.log(data);`
});
Error Log
If I click the row "Summary" then I should the following nested information
dataTable is not defined
ReferenceError: dataTable is not defined
at World.<anonymous> (/Users/src/__acceptance__/stepDefinition/android/wdio.apps.stepdefs.js:12:3)
at new Promise (<anonymous>)
at new F (/Users/wdio-cucumber-framework/node_modules/core-js/library/modules/_export.js:36:28)
Please help me to resolve this issue.....

I am not overly familiar with Webdriver-io, but it would appear that you are using a variable that is not defined. You are passing data into your function, but trying to use dataTable which is throwing the error.
Have you tried something like:
function(rowName, table) {
var myData = table.rowsHash();
console.log(myData);
console.log(table.raw());
}
Unrelated to your question, I would suggest separating your action steps from your validation steps
If I click the row "Summary"
Then I should see the following nested information
| Tax | 11.50 |
| Gratuity | 4.50 |
| Total | 26.59 |

You have a problem in your code on the stepDefinition file:
on the line data = dataTable.raw();... there is no variable dataTable defined.
Please try the below code:
Then(/^If I click the row "([^"]*)" then I should the following nested information$/, function (rowName, dataTable){
console.log(dataTable);
var data = dataTable.raw();
console.log(data);
data.forEach(function(element) {
console.log("Element:" + element[0]);
console.log("Element:" + element[1]);
}, this);
});

Related

Gatsby queries error with multiple queries error [duplicate]

To create the post template through this tutorial(I'm in part 4):
https://www.joaopedro.cc/blog-com-gatsby-e-react-parte-4
But when doing the "PostPage" query an error is occurring:
Multiple "root" queries found: "PostPage" and "PostPage".
Only the first ("PostPage") will be registered.
Instead of:
1 | query PostPage {
2 | markdownRemark {
3 | #...
4 | }
5 | }
6 |
7 | query PostPage {
8 | markdownRemark {
9 | #...
10 | }
11 | }
Do:
1 | query postPageAndPostPage {
2 | markdownRemark {
3 | #...
4 | }
5 | markdownRemark {
6 | #...
7 | }
8 | }
I've looked at other answers to similar questions, and from what I understand it was a case sensitive issue, but from what I see, everything is looking correct.
I'm not getting out of place. :( thanks in advance!
The error message here is actually quite helpful, but it doesn't take it all the way.
The issue is that you can only have a single query and you have multiple. The solution is to query for all the data you need in a single query rather than splitting it across multiple, as the error suggests.
Alas, you're trying to fetch what I imagine are two distinct data sets through the same field, which will give you another error by default. But there's an easy solution here: use aliases to de-duplicate the field name in the result.
query PostPage {
firstPost: markdownRemark {
#...
}
secondPost: markdownRemark {
#...
}
}
I had the same error today on Gatsby. There was one page Query and one Static Query used so the message was a bit misleading.
"This can happen when you use two page/static queries in one file"
The way this was tackled was I traced down the files that were using it. One of them was present but notice it was NOT in any way active in the project. Once it was removed the alert disappeared. So, in a nutshell, even if the file is NOT used anywhere the second identical Static Query is picked up.
In my case it was about having identical names of two page queries in two different pages.
Here's my setup:
in the pages folder, I have two components - index.tsx and account.tsx
both these components have this page query:
export const query = graphql`
query myquery($pathname: String) {
myquery(page: { eq: $pathname }) {
id
title
page
description
}
}
`
I got the error mentioned in the question
So, it turned out two queries in two different files but with the same name is forbidden.
In the end, I just used two different query names in my two files - myquery and myotherquery. Voila!
I just ran into the same error message with a React component that only used one StaticQuery. This component was copied in from another project (where it is working without any issues).
I've looked at other answers to similar questions, and from what I understand it was a case-sensitive issue...
This helped me to solve it - turned out that both the name of the React component as well as the StaticQuery were not propper camelCased (they contained "SEO" - all capital letters).
Error message is gone after cleaning this part up. I thought I share this as I found the error message in this context confusing.
ERROR #85910 GRAPHQL
Multiple "root" queries found: "SEOQuery" and "SEOQuery".
Only the first ("SEOQuery") will be registered.
Instead of:
1 | query SEOQuery {
2 | site {
3 | #...
4 | }
5 | }
6 |
7 | query SEOQuery {
8 | site {
9 | #...
10 | }
11 | }
Do:
1 | query seoQueryAndSeoQuery {
2 | site {
3 | #...
4 | }
5 | site {
6 | #...
7 | }
8 | }

How to refresh the laravel pagination when using ajax filtering data

I am using custom filter to filter my data in a div content
<div id="refresh">
<div/>
// pagination
{{ $lists->links() }}
It will displayed all data when display the site.
Previous | 1 | 2 | 3 | Next
After i filter data, the content will be refreshed but the pagination still remain unchanged.
Previous | 1 | 2 | 3 | Next
It should be 2 pages, since data filtered only 2 pages but it shows 3 pages.
Previous | 1 | 2 | Next
I am using ajax to filter the data by refreshing the content data. It works fine but just the pagination do not update. Any solution to solve this issue?
Try to use
<div id="refresh">
<div/>
<script type="text/javascript">
setInterval(function () {
$('#refresh').load(document.URL + ' #refresh');
}, 1000)
</script>

Calculating the sum of diffrent columns in TableView

I have a Table Witch look like the below table
TableVeiw<Transaction>
---------------------------------------------------------------------
| id | Transaction date | Name | type | Debit Amount | Credit Amount|
|---------------------------------------------------------------------|
| 1 | 21/02/2016 |Invoice|Credit | | 12000 |
|---------------------------------------------------------------------|
| 2 | 21/02/2016 |Payment|Debit | 20000 | |
|---------------------------------------------------------------------|
| Total Debit | Total Credit |
-----------------------------
The data in Debit amount and Credit amount come from one property of Transaction Object the code snnipet of how to populate those columns is below:
tcCreditAmmout.setCellValueFactory(cellData -> {
Transaction transaction = cellData.getValue() ;
BigDecimal value = null;
if(transaction.getKindOfTransaction() == KindOfTransaction.CREDIT){
value = transaction.getAmountOfTransaction();
}
return new ReadOnlyObjectWrapper<BigDecimal>(value);
});
tcDebitAmmout.setCellValueFactory(cellData -> {
Transaction transaction = cellData.getValue() ;
BigDecimal value = null;
if(transaction.getKindOfTransaction() == KindOfTransaction.DEBIT){
value = transaction.getAmountOfTransaction();
}
return new ReadOnlyObjectWrapper<BigDecimal>(value);
});
I need to calculate the total of :Total Debit(See the above table) and Total Credit (See the above table) every time the TableView item changes via Javafx Bindings, but i have no idea how to acheive this.
Note: Total Debit and Total Credit are Labels ,
Assuming you have
TableView<Transaction> table = ... ;
Label totalDebit = ... ;
Label totalCredit = ... ;
then you just need:
totalDebit.textProperty().bind(Bindings.createObjectBinding(() ->
table.getItems().stream()
.filter(transaction -> transaction.getKindOfTransaction() == KindOfTransaction.DEBIT)
.map(Transaction::getAmountOfTransaction)
.reduce(BigDecimal.ZERO, BigDecimal::add),
table.getItems())
.asString("%.3f"));
and of course
totalCredit.textProperty().bind(Bindings.createObjectBinding(() ->
table.getItems().stream()
.filter(transaction -> transaction.getKindOfTransaction() == KindOfTransaction.CREDIT)
.map(Transaction::getAmountOfTransaction)
.reduce(BigDecimal.ZERO, BigDecimal::add),
table.getItems())
.asString("%.3f"));
If getAmountOfTransaction might change while the transaction is part of the table, then your table's items list must be constructed with an extractor.

WebFocus, two title columns and merging cells

If i have a table in a WebFocus Raport design
+--------+---------+--------+---------+
| left_1 | right_1 | left_2 | right_2 |
+--------+---------+--------+---------+
| v11 | p11 | v21 | v21 |
+--------+---------+--------+---------+
| v12 | p12 | v22 | v22 |
....
How to do a such table with syllabus column titles:
+-------+-------+-------+-------+
| One | Two |
+-------+-------+-------+-------+
| left | right | left | right |
+-------+-------+-------+-------+
| v11 | p11 | v21 | v21 |
+-------+-------+-------+-------+
| v12 | p12 | v22 | v22 |
....
Thank you
Sorry for the delay of the answer :)
To rename columns, with the AS command. Example:
TABLE FILE SYSTABLE
PRINT NAME
COMPUTE LEFT1/A3 = 'v11'; AS 'left';
COMPUTE RIGHT1/A3 = 'p11'; AS 'right';
COMPUTE LEFT2/A3 = 'v21'; AS 'left';
COMPUTE RIGHT2/A3 = 'p21'; AS 'right';
IF RECORDLIMIT EQ 10
END
To put the heading columns, you can work with the ACROSS command but it will be more tricky that if u use simply SUBHEAD. With the same example:
TABLE FILE SYSTABLE
PRINT NAME NOPRINT
COMPUTE LEFT1/A3 = 'v11'; AS 'left';
COMPUTE RIGHT1/A3 = 'p11'; AS 'right';
COMPUTE LEFT2/A3 = 'v21'; AS 'left';
COMPUTE RIGHT2/A3 = 'p21'; AS 'right';
IF RECORDLIMIT EQ 10
ON TABLE SUBHEAD
"<+0>One<+0> Two"
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN, PAGESIZE='Letter',
LEFTMARGIN=0.500000, RIGHTMARGIN=0.500000,
TOPMARGIN=0.500000, BOTTOMMARGIN=0.500000,
SQUEEZE=ON, GRID=OFF, ORIENTATION=LANDSCAPE, $
TYPE=REPORT,FONT='ARIAL',SIZE=9,$
TYPE=TABHEADING,HEADALIGN=BODY,$
TYPE=TABHEADING, LINE=1, ITEM=1, COLSPAN=2, SQUEEZE=ON,$
TYPE=TABHEADING, LINE=1, ITEM=2, COLSPAN=2, SQUEEZE=ON,$
ENDSTYLE
END
Hope it helps!
I'm not entirely sure if you load the headers as a field or if that is the field name
But this might help you
Define fields
TITL1/A3 = 'One';
TITL2/A3 = 'Two';
BLANK/A1 = '';
Edit the Left and Right title fields to remove the _1 or _2
Print the fields BY BLANK NOPRINT
Add
ON BLANK SUBHEAD
"
You can also add more rows to the subhead if you need more titles
You can easily do it by embedding HTML/CSS scripts in report(.fex) file.
just add the HTML/css code at the end of the file.
For eg.
-HTMLFORM BEGIN // to start styling your generated report table with HTML/CSS
TABLE tr
td:first-child // applies on 1st row ONLY.It can be td or th.
{
colspan = "2"; //to merge 2 columns
}
-HTMLFORM END //end HTML.
So the first row must have two cells having title "ONE" and "TWO"(in your case), and both cells must have property of colspan = "2"
Also you can refer:
Colspan propery from here
manipulating first row of table from here
Second option is to write the whole code in a file and save it in .htm/.html format and just insert the file in to WEBFOCUS(.fex) file.For eg.
-HTMLFORM BEGIN
-INCLUDE HTML_FILE.HTML
-HTMLFORM END
Hope it helps.Thanks.

Preconfigured Magento Widgets

Is there a UI or programatic system for taking advantage of the "Preconfigured Widget" functionality that's part of Magento's CMS page rendering?
When adding a widget to a CMS page, the code that renders that widget is located in the template directive processing class. This code
File: app/code/core/Mage/Widget/Model/Template/Filter.php
class Mage_Adminhtml_Cms_PageController extends Mage_Adminhtml_Controller_Action
{
...
}
When loading a Widget's paramaters, there the following bit of code
// validate required parameter type or id
if (!empty($params['type'])) {
$type = $params['type'];
} elseif (!empty($params['id'])) {
$preconfigured = Mage::getResourceSingleton('widget/widget')
->loadPreconfiguredWidget($params['id']);
$type = $preconfigured['type'];
$params = $preconfigured['parameters'];
} else {
return '';
}
This code appears to parse a widget directive tag for an id value
{{widget name="foobazbar" id=""}}
and then load the configuration from a widget model
public function loadPreconfiguredWidget($widgetId)
{
$read = $this->_getReadAdapter();
$select = $read->select();
$select->from($this->getMainTable())
->where($this->getIdFieldName() . ' = ?', $widgetId);
var_dump((string)$select);
$widget = $read->fetchRow($select);
if (is_array($widget)) {
if ($widget['parameters']) {
$widget['parameters'] = unserialize($widget['parameters']);
}
return $widget;
}
return false;
}
When I first encountered this code, I assumed it was loading up a Widget Instance model. However, it's not. Instead it's loading data from a widget/widget class, which corresponds to the widget table.
mysql> describe widget;
+------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+----------------+
| widget_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| code | varchar(255) | NO | MUL | NULL | |
| type | varchar(255) | NO | | NULL | |
| parameters | text | YES | | NULL | |
+------------+------------------+------+-----+---------+----------------+
Is there a UI or system for adding data to this table? Does anyone (who works fro Magento Inc. or not) know if this is a supported feature, or if it's the start of something that's been abandoned, but left in for backward compatibility reasons?
This answer is somewhat off-topic, but I'm not sure if it might satisfy your need anyway. I've discovered that you can create widget instances in the admin CMS>Widgets section, and then render them via the following code:
$oWidget = Mage::getModel('widget/widget_instance')->load('HomepageTwitter','title');
$oWidgetBlock = Mage::app()->getLayout()->createBlock($oWidget->getType(), $oWidget->getTitle(), $oWidget->getWidgetParameters());
echo $oWidgetBlock->toHtml();
Note that the block is loaded by title (rather than arbitrary ID), and that the widget parameters are passed for the Block to render.
Per several comments, and private emails, it appears this is a privatish feature for the Magento core team, and has nothing to do with Instance Widgets.

Resources