In WATIRwe use #current_page whenever we lands to page which got created at run time (during test case execution).
I am looking for similar feature in Geb.
Here I have two Pages
RegistrationPage.groovy
where I have provided
static url = "/register.html"
I also have UserProfilePage.groovy
here I can't provide any static url because it gets created once I submit the Registration Page, it changes as per user name
example https://xxxxx.com/paul.html, if two paul's are there then https://xxxxx.com/paul2.html
I want to use
static content = {
defaultprofilePic {$("#userprofilepic")}
}
declared in UserProfilePage.groovy
If I am not using to keyword it would land me back to baseURL and if I use it gives exception that element not available on this page.
But I think if I use could something like #current_page it would pass
You should use at(UserProfilePage) which sets the current page to be an instance of UserProfilePage and also verifies its at checker.
Related
I have multiple buttons and form inputs in one page. All these buttons and form inputs need to be disabled or enabled depending on a condition.
I know that it is possible to use the disabled keyword inside a tag to disable a specific input or button. Also, I can just add the code
:disabled="true"
to disable the inputs depending of the boolean value of a variable.
However, this solution is not acceptable for me, since I will have to add this line of code to every inputs on my page (I may create new pages in the future, containing as many inputs).
I would like to know if there's a way that allows me to simply disable the parent container of all the inputs so that the children item (the inputs) are disabled.
If you inspect the Vue instance itself of the VM when running your code you can have something like this when you console.log(this),
It will give you output similar to this if you use the correct scope:
{
$attrs
$options
.......
$el
}
Inside $el there's object properties for accessing firsElementChild, previousElementChild, previousElementSibling, etc. There's a lot of HTML related properties, however, accessing HTML element this way can get messy pretty fast. I think that your best solution is the one you already mentioned or changing the CSS class dynamically.
If you use v-if to conditional render on a parent you can achieve pretty similar functionality too.
See: Conditional rendering
I was wondering is there a way to use several page objects within one test without having to specify a url in each page object file.
All tests start on the login page launched using the launch_url parameter & navigate to several other URLS via button clicks
I want page objects to only contain element selectors.
I have tried using variable declarations such as
`var loginButton = loginPage.elements.login.selector`
but this is not really any advantage over declaring the selectors in a javascript file I can import at the start of the test
You can reference the elements from each page object without assigning them to variables. The syntax is a little different than you would expect. Here is how I do it in my tests.
Let's say I login to my app, land on a dashboard, and then navigate to an admin menu and verify some element is visible on that page. My test would look something like this (assume I've already setup my page object variables in a before hook):
'Test example 1': (browser) => {
loginPage.setValue('#usernameInput', username);
.setValue('#passwordInput', password)
.click('#loginBtn');
dashboardPage.waitForElementVisible('#mainMenu', 1000, () => {
dashboardPage.click('#mainMenu')
.click('#adminMenuOption');
adminMenuPage.verify.visible('#someElement');
}
}
Everywhere you see #elementName should match up with what you have named the element in your page object.
I have come across what appears to be an inconsistency in MVC 5 regarding the Html.Actionlink. In different cshtml files I can use the same code, but the url target that is generated is different.
For example, this line of code:
<td>#Html.ActionLink(item.Description, "Edit", new { item.ParentTableID }) </td>
generates this URL
localhost\MyControllerClass\Edit?ParentTableID=35
That then properly calls the ActionView method Edit and feeds the parameter with 35 as expected.
However, in another cshtml file, this line
<td>#Html.ActionLink("Edit", "EditChild", new { id = f.ApplicationTableFieldID})</td>
produces this url
localhost/MyControllerClass/Edit/7
and when it hits the EditChild Action View, the parameter is null.
I have seen this now a couple of times and not yet been able to understand what makes the difference. But I need the first result.
Thanks.
Ensure that your ID parameters are named correctly in both your Action method and your ActionLink Html helper. The visual difference comes from MVC default routing and how it can take a parameter named ID and put it in the URL without the query string (? followed by stuff)
If your action method looks like this
public ActionResult EditChild(int ParentTableID){}
Then you will need to have your ID parameter named ParentTableID when you pass it back in your URL
<td>#Html.ActionLink("Edit", "EditChild", new { ParentTableID = f.ApplicationTableFieldID})</td>
Should now produce the following URL
localhost\MyControllerClass\EditChild?ParentTableID=3
I have two pages, one page for input, another page for the options, how to send value form page to another page on xPages Mobile Controls, or is there another way to make like this.
See my sample page:
1. Page 1:User Input
http://i1248.photobucket.com/albums/hh490/dannysumarnach/page_1_form_user_input.jpg
Page 2:Picklist
http://i1248.photobucket.com/albums/hh490/dannysumarnach/page_2_user_choice_PickList.jpg
note: the built-in typeahead not posible
Regards,
Danny
The in built type ahead is missing the dojo tundra.css file when using the single page app control. This file comes with Dojo its just not being included. Import this file to get the type ahead to work.
I'm unsure as to what you mean about passing value from one page to another, you can submit data to a document and open it in another page, add it to a scoped variable, add a parameter to the URL. All of these options will work.
Have a look at my blog post on this topic. There are a couple of gotchas to get around, most notably, ensuring the the page with your document datasource gets recalculated at the correct time. I'm working on a NotesIn9 on it.
Part 3 covers a couple of amendments to get it working with existing documents and includes a sample page that will work in the Extension Library Demo db. Note the extra view that needs to be created and other details in Part Two.
http://www.intec.co.uk/xpages-mobile-controls-and-value-pickers-part-three-client-side-approach-extended/
** New EDIT **
so what I'm trying to do is this.
I want the to add new form elements generated by my module on the product view of the following url
http://magento.example.com/catalog/product/view/id/46
ultimately these elements will be determined to show up by a related table in my module
I expected that if I extended Mage_Catalog_Block_Product_View in my module as shown below I would be able to create a block in the product form that would contain such form fields, only if he are in the related table in my module
so I created a test.phtml file in
app/design/frontend/default/default/templates/<module>/test.phtml
then as you can see in my the View.php file described bellow I built the block and displayed it in the product view.
It did appear but 5 times too many. from the answers below this is normal so that answers the question as to why the it shows up five times but leaves the question what is the proper way to proceecd since this plan is not going to work
** End New Edit **
in my module I call _prepareLayout() and it does this 5 times when i pull up the page
here's my code
in
/app/code/local/Namespace/Module/Product/Veiw.php
class <Namespace>_<module>_Block_Product_View extends Mage_Catalog_Block_Product_View {
protected function _toHtml() {
return parent::_toHtml();
}
public function _prepareLayout() {
$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'my_block_name_here',
array('template' => '<module>/test.phtml')
);
if ($block){
$this->getLayout()->getBlock('content')->insert($block)->toHtml();
}else{
echo "no block";
}
return parent::_prepareLayout();
}
}
NOTE:
I just noticed this also takes away the price availability qty and add to cart button. which is also a problem
EDIT
First I want to thank you all for your answers. Second i want to give you more context
the reason for choosing to do this in the module is that I don't want the block to show up on every product . What i have is a table of what I'll call custom options containing properties of the product sort of like hair color height weight etc and depending on what set of properties are attached to the product (if any) will depend on what html content will show up on the page.
so in one case it my get a drop down menu and in another case it may get an input box. the other very important piece is that this must be setup so that I can give the end result out as a module that can be installed and not worrry that it won't show up if someone upgrades there magento
that said does it still make sense to do this all in the xml file ?
It seems to me that your code is overriding a core Magento module in order to achieve what could be easily done in the layout xml configuration. I would strongly recommend the follwing:
Use the built-in configuration mechanisms (e.g. layout xml - read Alan's excellent tutorial here) instead of writing code whenever possible.
Don't override the core code
if you must change the behaviour of the core code, use an Observer rather than Rewrite/Override
if you absolutely must Override, always call parent::whatever()
For example, if you create a <module>.xml layout file in your theme (app/design/frontend/default/<theme>/layout), you could use the following code:
<catalog_product_view>
<reference name="content">
<block type="module/block" name"my_block_name_here" template="module/test.phtml"/>
</reference>
</catalog_product_view>
You would then need to use a getChildHtml('my_block_name_here'); call within your phtml to position the block.
So unless there is other functionality happening inside your _prepareLayout, there's no need to override the core, or even to override the default catalog.xml.
EDIT (small edit above)
So now in your Block (I would recommend that you call it Namespace_Module_Block_Product_Customattributes or something like that), you are not overriding the core Product_View block, but merely processing your logic for what html widgets to use to render your custom attributes. Leave the rest of the tier prices, add to cart, other generic product block code, etc to Magento to work out.
If you are worried about the upgrade path for your module's users, you should definitely NOT be overriding core code. Use the configuration approach and very selectively introduce code that "plays nice" with the system rather than try to boss it around with overrides.
I took a look at a stock Magento install of CE 1.4.1, and unmodified the _prepareLayout method is called six times when loading the URL
http://magento.example.com/catalog/product/view/id/46
That's because the class is instantiated six times. So that's the correct behavior.
As for the vanishing element, I can'y say for sure, but your override to _prepareLayout doesn't appear to either
Do the same things as Mage_Catalog_Block_Product_View::_prepareLayout
Call parent::_prepareLayout();
When you override a class in a Magento you're replacing an existing class with your own. If you change a method, you're responsible for that old code being run.
It's not clear what you're trying to accomplish here. You should consider breaking your problem down into smaller problems, and then posting one (or more) "I tried X, expected Y, and got Z" type questions. As written no one's going to be able to answer your question.