Wrong tab configuration on Magento - magento-1.5

I have a huge problem with an magento extension I developed. Localhost everything is fine but when I deploy, it get this error.
Wrong tab configuration
#0 [internal function]: Mage_Adminhtml_Block_Widget_Tabs->addTab('pricematrix', 'tab_pricematrix')
#1 /var/www/vhosts/discountprint.dk/httpdocs/app/code/core/Mage/Core/Model/Layout.php(347): call_user_func_array(Array, Array)
#2 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Model/Layout.php(213): Mage_Core_Model_Layout->_generateAction(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#3 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Model/Layout.php(209): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#4 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(343): Mage_Core_Model_Layout->generateBlocks()
#5 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(270): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#6 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Adminhtml/Controller/Action.php(263): Mage_Core_Controller_Varien_Action->loadLayout(Array, true, true)
#7 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(246): Mage_Adminhtml_Controller_Action->loadLayout(Array)
#8 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_ProductController->editAction()
#9 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('edit')
#10 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front->dispatch()
#12 /var/www/vhosts/something.dk/httpdocs/app/Mage.php(627): Mage_Core_Model_App->run(Array)
#13 /var/www/vhosts/something.dk/httpdocs/index.php(80): Mage::run('', 'store')
#14 {main}
I Googled it for hours but can't find any useful information. My magento version is 1.5.0.1
Hope you can help

You'll get a lot farther if you stop searching Google and start searching your code.
Search for the exception string "Wrong tab configuration"
$ ack 'Wrong tab configuration'
Adminhtml/Block/Widget/Tabs.php
108: throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
112: throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
Look at that, there's only two possible places in the entire source tree that could be throwing that exception, both in the addTab method your stack-trace indicated was being called. Looking at that code in context
public function addTab($tabId, $tab)
{
if (is_array($tab)) {
$this->_tabs[$tabId] = new Varien_Object($tab);
}
elseif ($tab instanceof Varien_Object) {
$this->_tabs[$tabId] = $tab;
if (!$this->_tabs[$tabId]->hasTabId()) {
$this->_tabs[$tabId]->setTabId($tabId);
}
}
elseif (is_string($tab)) {
if (strpos($tab, '/')) {
$this->_tabs[$tabId] = $this->getLayout()->createBlock($tab);
}
elseif ($this->getChild($tab)) {
$this->_tabs[$tabId] = $this->getChild($tab);
}
else {
$this->_tabs[$tabId] = null;
}
if (!($this->_tabs[$tabId] instanceof Mage_Adminhtml_Block_Widget_Tab_Interface)) {
throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
}
}
else {
throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
}
It looks like your call is running through the second if/else branch. Your tab string, tab_pricematrix, is used to fetch a child block from the current tab
$this->_tabs[$tabId] = $this->getChild($tab);
However, it looks like whatever it finds in there isn't a child of Mage_Adminhtml_Block_Widget_Tab_Interface.
My guess is that's because the call to getChild is returning false because your module hasn't added a tab with the name tab_pricematrix to the layout (did you copy the Layout XML files to the new server?) Without knowing how you've implemented that module, it's impossible to say for sure.
Good luck!

Normally localhost problems that don't appear on a live site are to do with filesystem case sensitivity. Most developers in my experience develop on Windows / Mac OSX, which by default aren't case sensitive. But most production environments are some kind of *nix system. One thing that has tripped me up in the past is having a filename with a capital letter in the middle.
For example if a block is FooBar.php and sits in Mage_Core, when loading the model you must use...
Mage::getModel('core/fooBar');
The string is automatically ran through ucwords, but obviously any camel casing in your file naming will need to be taken into account when requesting a model/block etc.

Related

Is it possible in CucumberJs & Cypress to make contexts independent and allow steps with same description?

I've a Cypress and CucumberJs setup based on typescript for end to end tests in a project I'm working on.
It happens to have two different feature files bus.feature and car.feature with their step definition files bus.spec.ts and car.spec.ts
I've two different step definitions:
Then(
'I {string} the Destination page', (operation: operation) => {
cy.location().should(location => {
switch (operation) {
case 'visit':
expect(location.pathname).to.eq('/e2e/destination')
break
case `can't visit`:
expect(location.pathname).to.eq('/e2e/bus')
break
}
})
}
)
and
Then(
'I {string} the Destination page', (operation: operation) => {
cy.location().should(location => {
switch (operation) {
case 'visit':
expect(location.pathname).to.eq('/e2e/destination')
break
case `can't visit`:
expect(location.pathname).to.eq('/e2e/car')
break
}
})
}
)
identical in their recognitional string 'I {string} the Destination page' but slightly different in the implementation (for instance the case can't visit).
When I run the tests, the bus one is fully executed perfectly.
The car one has an issue because, being the recognitional string the same for both tests, the Cypress+CucumberJs suite detect just the first bus definition, ignoring the car and proper one.
I understand why, the first one is detected and that's it.
Question is, is there a way to separate contexts of different files, so being able to have also same definition name with different implementation?
Thanks in advance
Why not
'I {string} the Destination page for {string}', (operation: operation, transportMode) => {
...
expect(location.pathname).to.eq(`/e2e/car${transportMode}`)
or does that mess up the matching between feature and step?

BluetoothLeScanner never calls any of its callback methods

I'm very new to Android and Kotlin so I may be getting something very simple wrong, but as far as I can see when I call BluetoothLeScanner.startScan() none of the possible callback methods of the ScanCallback class which I've created is ever called.
I've understood that at API level 23 & above just putting the location permissions in the manifest may not be enough so I've written code to handle that & am satisfied that my App has both COARSE and FINE location permissions
Here's my override of the OnScanResult method:
override fun onScanResult(callbackType: Int, result: ScanResult?) {
super.onScanResult(callbackType, result)
mScan = true
}
I've put a break point in each of the callback methods and when I hover over these breakpoints while the code is running, I see the message "No executable code found at line..." That's a pretty disturbing message (and I suspect is pointing to where the problem lies) but (a) how can there be no code there when everything builds OK and (b) what do you do about it?
Update on that: I think that message is a red herring. I've now moved the break points to elsewhere within the callback functions and I no longer see the 'no executable code' message. Looks like Android Studio lets you put a break point on a line with no actual code in it!
So we're back to the original question - why are we getting no callbacks?
Looks like this is now solved:
(1) I did find a setting on the phone as distinct from turning on Location. It was enable Bluetooth scanning. However it actually made no difference (2) What looks to have been the real issue is a misunderstanding of the meaning of the string which you pass to the ScanFilter Builder with setDeviceName(). There is a string in our hardware Bluetooth module which we're trying to scan for which is called device name, and I was scanning for that. When I looked instead for the Beacon advertising data, it found it.
Many thanks for suggestions (only 1 I think)
Giving permissions in the manifest is not the same as the app using it.
For ble you need to give the location and bluetooth permission. Then:
in the app(on the phone) browse your open apps
find your app and click the 3 dots in the top left
Click app info
Permissions
Toggle location to on
Also the following is a handy bit of code:
public void checkPermission() {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
} else {
ActivityCompat.requestPermissions(this, new String[]{
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,}, 1);
}
}
}
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
if (requestCode == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
} else {
checkPermission();
}
}
Ps Be safe all

nodejs+selenium-driver NoSuchElementError & StaleElementReferenceError

I am doing a test based mocha. node v8.2.1, selenium-webdriver: ^3.5.0.
test.it('demoClass', () => {
driver.classes[0].findElement(By.css('.class-avatar')).click();
driver.wait(until.elementIsVisible(driver.findElement(By.css('.anticon.anticon-plus'))));
//driver.sleep(2000);
driver.findElement(By.css('.anticon.anticon-plus')).click();
})
I am getting two different types of errors, either its NoSuchElementError: no such element: Unable to locate element: or StaleElementReferenceError: stale element reference: element is not attached to the page document
But whichever error, its refer to line:
driver.findElement(By.css('.anticon.anticon-plus')).click();
When I use driver.sleep(2000), its getting resolved. In my opinion, It's the question of animation. I can get the element(.anticon.ancicon-plus) only at the time, the page's animation is completed.
what I am confused is that I use driver.wait(until.elementIsVisible()) without an error, It's obvious that I got the element. but at the next line, I can't use it. Or NoSuchElementError, or StaleElementReferenceError.
I find some answer like http://www.seleniumhq.org/exceptions/stale_element_reference.jsp,https://stackoverflow.com/questions/18225997/stale-element-reference-element-is-not-attached-to-the-page-document. But It can't help me.
when use driver.findElement, something terrible will be triggered. use javascript instead it.
driver.executeScript(function() {
while(true) {
if(!document.querySelector('.anticon.anticon-plus')){}
else {
document.querySelector('.anticon.anticon-plus').click();
break;
}
}
return true; // not neccessary
})

How to catch when target is found using Vuforia for iOS?

I need a simple way to detect when a target has been found or lost so that I can segue to a different Controller.
This question has been asked in several forums, but there was never a satisfactory answer. This particular post seems to be the most detailed, but it is over three years old.
https://developer.vuforia.com/forum/ios/trackableeventhandler-equivalent-ios
I can't find any documentation related to this on the Vuforia site.
One of the methods that must be implemented by the VuforiaManagerDelegate is:
func vuforiaManager(_ manager: VuforiaManager!, didUpdateWith state: VuforiaState!)
When a target is found (an image is recognized by Vuforia) this property will change from 0 to 1 (or more, if multiple targets are identified):
numberOfTrackableResults
So it is simply a matter of checking if state.numberOfTrackableResults > 0 { your code here }
on TrackableEventHandler script there is a function called OnTrackableStateChanged
you can sign up to this and do whatever you wanna do directly here or in OnTrackingFound();
public void OnTrackableStateChanged(
TrackableBehaviour.Status previousStatus,
TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
OnTrackingFound();
}
else
{
OnTrackingLost();
}
}

General Problems With Geb (StaleElementReferenceException & Wait Timeouts)

According to the "Book of Geb" I started to map our portal's web pages. I prefer to use variables defined within static content closure block and accessing them afterwards in page methods:
static content = {
buttonSend { $("input", type: "submit", nicetitle: "Senden") }
}
def sendLetter() {
waitFor { buttonSend.isDisplayed() }
buttonSend.click()
}
Unfortunately, sometimes I get an Geb waiting timeout exception (after 60 secs) or even worse I receive the well known "StaleElementReferenceException".
I could avoid the wait timeout when using "isEnabled" instead of "isDisplayed" but for the "StaleElementReferenceException" I could only apply the below solution:
def sendLetter() {
waitFor { buttonSend.isEnabled() }
try {
buttonSend.click()
} catch (StaleElementReferenceException e) {
log.info(e.getMessage())
buttonSend.click()
}
}
I guess, this solution is not really nice but I could not apply an explicitly wait as described in another article. Thus, I have some general questions:
Should I avoid to use static content definitions when pages are dynamically?
At what time or event Geb is refreshing its DOM? How can I trigger the DOM refreshment?
Why I still get a "StaleElementReferenceException" when using CSS selectors?
I would appreciate every hint which helps to understand or to solve this issue. The best would be to have a simple code example since I'm still a beginner. Thank you!
If you defined an at check on your page class the page would first verify that condition and wait for the first n seconds. Which is assigned in your gebConfig file. The default is 30 seconds.
static at = {
waitFor { buttonSend.isDisplayed() }
}
Thus once you call your pages 'to' method with a test or whatever you are using it for the page will wait and then perform your page manipulations.
to MyPage
buttonSend.click()
Should I avoid to use static content definitions when pages are dynamically?
No. Actually, the static definitions are of closures. So what is
actually happening is each time you make use of that Pages static
components you are calling a closure which is run dynamically on the
current page(collection of webElements). Understanding this is key to
using Geb and discovering the problems you will run into.
At what time or event Geb is refreshing its DOM? How can I trigger the DOM refreshment?
When you call: to, go, at, click ,withFrame(frame, page), withWindow
and browser drive methods it will refresh the current set of
WebElements. Geb has a nice collection of utiliities to make switching
between pages and waiting for page manipulations easy. Note: Geb is
actually built on WebDriver WebElements.
Why I still get a "StaleElementReferenceException" when using CSS selectors?
It is possible the page hasn't finished loading, has been manipulated
with ajax calls or has been refreshed in some other way. Sometimes an
'at' PAGE method call can fix these issues. They are for me most
common when using frames as Geb seems to become confused between pages
and frames a little. There are workarounds.
In short if you use the page pattern you can easily switch expected pages using the Page class you have defined with a static content, at, and url closure using the below:
to(Page)
at(Page)
Navigator.click(Page)
withFrame(frame, Page) { }
In addition to twinj's answer, I would like to point out a couple of other workarounds in case you encounter a StaleElementReferenceException.
Often times I find it is better to write out your selector manually rather than rely on the contents as defined in the page. Even though your page contents should not be cached by default, they still manage to slip away from me at times. This is particularly prevalent when dealing with dynamic content or iterations.
Ex: Let's say we want to click an element from a dynamically created dropdown.
Typically you might want to do something like...
static content = {
dropdown { $("#parentDiv").find("ul") }
}
void clickDesiredElement(String elementName) {
dropdown.click()
def desiredElement = dropdown.find("li", text:elementName)
waitFor { desiredElement.displayed }
desiredElement.click()
}
If this doesn't work, try getting rid of the contents altogether, and writing out the selector manually...
void clickDesiredElement(String elementName) {
$("#parentDiv").find("ul").click()
def desiredElement = $("#parentDiv").find("ul").find("li", text:elementName)
waitFor { desiredElement.displayed }
desiredElement.click()
}
In really nasty cases, you may have to use a manual timer, as pointed out in this answer, and your code may look like this...
void clickDesiredElement(String elementName) {
$("#parentDiv").find("ul").click()
sleepForNSeconds(2)
def desiredElement = $("#parentDiv").find("ul").find("li", text:elementName)
waitFor { desiredElement.displayed }
desiredElement.click()
}
Keep in mind this is a workaround :)
For large iterations and convenient closure methods, such as each{} or collect{}, you may want to add a waitFor{} in each iteration.
Ex: Let's say we want to get all rows of a large table
Typically you might want to do something like...
def rows = $("#table1").find("tr").collect {
[
name: it.find("td",0),
email: it.find("td",1)
]
}
Sometimes I find myself having to do this iteratively, along with a waitFor{} between each iteration in order to avoid a StaleElementReferentException. It might look something like this...
def rows = []
int numRows = $("#table1").find("tr").size()
int i
for(i=0; i < numRows; i++) {
waitFor {
def row = $("#table1").find("tr",i)
rows << [
name: row.find("td",0),
email: row.find("td",1)
]
}
}
I have figured that it is the navigator which get lost when you load dynamically.
I've solve the issue locally by reinit the page or module with below code:
void waitForDynamically(Double timeout = 20, Closure closure) {
closure.resolveStrategy = Closure.DELEGATE_FIRST
switch (this) {
case Module:
init(browser, browser.navigatorFactory)
break
case Page:
init(browser)
break
default:
throw new UnsupportedOperationException()
}
waitFor {
closure()
}
}

Resources