I am facing issue with relative x-path. I am able to fetch x-path with 'id' attribute only, not with class, name. I have unchecked 'generate absolute x-path'. Can someone help?
xpath example:
//*[#name=’name_value’]
or if has a long name and you want to select by a part of that name
//*[contains(#name, ’name_value’)]
Same for class,change #name with #class
Related
I have the following XML:
<envelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="vendor">
<fizz buzz="3"/>
</payload>
</envelope>
I am trying to write an XPath expression that will pluck out vendor (value for the payload's class attribute) or whatever its value is.
My best attempts are:
/dataEnvelope/payload[#class="vendor"]#class
But this requires the expression to already know that vendor is the value of the attribute. But if the XML is:
<dataEnvelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="foobar">
<fizz buzz="3"/>
</payload>
</dataEnvelope>
Then I want the expression to pluck out the foobar. Any ideas where I'm going awry?
If you need #class value from payload node, you can use
/dataEnvelope/payload[#class]/#class
or just
/dataEnvelope/payload/#class
At first, your two XML files are out-of-sync - one references envelope and the other references dataEnvelope. So exchange one for the other, if necessary.
So, to get the attribute value of payload, you can use an XPath expression like this which uses a child's attribute value to be more specific:
/envelope/payload[fizz[#buzz='3']]/#class
Output is:
vendor
If the document element can/will change, then you can keep the XPath more generic and select the value of the class attribute from the payload element that is a child of any element:
/*/payload/#class
If you know that it will always be a child of envelope, then this would be more specific(but the above would still work):
/envelope/payload/#class
In order to find all attributes with name myAttr in the document I can do this //#myAttr but what if I want to specify the root and still find all attributes with that name in the document? Something like /root/{whatever_or_nothing}/#myAttribute
How about this way :
/root//#myAttribute
I want to add a new field that contains the name of the table that had that order in the pos receip of the resaturant module, I already have searched for similar examples but couldn't solve this
I first added the variable that containes the name of the table in the models fields (this variable is in the restaurant_table class so I have done an inheritance to the restaurant_printer class) :
pos_restaurant\static\src\js\multiprint.js
model: 'restaurant.printer',
fields: ['name','proxy_ip','product_categories_ids','name_table'],
seconde I have added this line in the pos_restaurant\static\src\xml\printbill.xml
<div id="name_table" style="text-align:center;"></div>
but nothing had changed in the ticket any ideas please?
for all poeple who has interest in this I figured out how to add that field so first I thought that only the pos restaurant module files that needs to be modified so I was wrong and it's what it was all about,so the main file that should be modified is the addons\point_of_sale\static\src\xml\pos.xml ,to specifiy it's the PosTicket template,so the modification showed up right away because after all that restaurant module depends on the main point of sale
I added my code just after the shop widget like :
Table: <t t-esc="widget.pos.table.name"/><br />
and name of the table was added in the printed ticket
hope this helps you
To add fields in POS ticket you also need to add fields in 2 place
i) Need to add models.js file of Point of Sale. In that file there is method name "export_for_printing" under that method need to add your custom field. I added under "var receipt" name variable.
ii) After addded there to view in UI you need to add in PosTicket template located in pos.xml templates.
<t t-name="PosTicket">
Under this template your customized field needs to be added.
I have the following url:
http://www.mydomain.com/display/23
// 23 is the companyid, and i want there to be company name
I would like to display it like
http://www.mydomain.com/display/company-name-here
Is it possible to fetch the company name from my controller somehow? Is this possible in the Codeigniter? How can i get the company name from my controller in the routes.php file? I check the CI documentation but I found...nothing.
Regards, John
Open application/config/route.php and add following route path
$route['display/company-name-here'] = 'display/index/23';
Hope display is controller name and you will have to use there index function.
Or another possible way
$route['display/(:any)'] = 'display/index/$1';
Note your link should be http://www.mydomain.com/display/index/company-name-here-23
the link will be converted
http://www.mydomain.com/display/company-name-here-23
I'm using following spec with MiniTest::Spec and Capybara:
find_field('Email').must_have_css('[autofocus]')
to check if the field called 'Email' has the autofocus attribute. The doc says following:
has_css?(path, options = {})
Checks if a given CSS selector is on the page or current node.
As far as I understand, field 'Email' is a node, so calling must_have_css should definitely work! What I'm doing wrong?
Got an answer by Jonas Nicklas:
No, it shouldn't work. has_css? will check if any of the descendants
of the element match the given CSS. It will not check the element
itself. Since the autofocus property is likely on the email field
itself, has_css? will always return false in this case.
You might try:
find_field('Email')[:autofocus].should be_present
this can also be done with XPath, but I can't recall the syntax off
the top of my head.
My solution:
find_field('Email')[:autofocus].must_equal('autofocus')
Off top of my head. Can you use has_selector?(). Using Rspec wit Capy:
page.should have_selector('email', autofocus: true)
Also check Capybara matchers http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers
I've not used MiniTest before but your syntax for checking for the attribute looks correct.
My concern would be with your use of find_field. The docs say:
Find a form field on the page. The field can be found by its name, id or label text.
It looks like you are trying to find the field based on the label. If so I would check that you have the for attribute on it and and that it has the correct id of the form field you are looking for. To rule out this being the issue you could temporarily slap an id your form field and look for that explicitly.