Selecting the next formfield with Selenium RC and python - python

I am running an automated test to test a webform for my company. They have just installed a zipcode service which automatically adds the Street and City/Region when you fill in the Address and housenumber.
This autofill appears when you deselect the last form element (e.g. that of the housenumber).
This is the order of the fields I'm using;
form:zipcode
form:housenumber
form:addition (optional)
form:street (gets filled in by service after zipcode and housenumber are provided)
form:city (the other autofill field)
When you fill this form out manually, the address appears as soon as you click or tab into the addition field (as it is optional) but when it's done automated it doesn't work.
I have tried several things like;
focus('form:addition') or
select('form:addition') but these don't work. I have tried
type('\t') to tab to the form field, and
type('form:addition', ' ') to type a space into the add. field and even
type('form:addition', "") to leave it empty. None of these attempts have worked so far.
Is there anyone that can help me with this?

Hi i got a solution for this i think,
problem is with generating the user interactions to the addition field.
use these statements
focus("form:addition");
keyPressNative("10") //this is ENTER command
it should work

Yesterday I found out that the zipcode service uses an Ajax call to retrieve the information. This call is executed when the zipcode and housenumber fields are both 'out of focus' (i.e. deselected).
The right statement I found to use this in my advantage is this;
selenium.fireEvent('form:number', 'blur') which deselects the last field where data was entered.

Related

rtcclient ownedBy returns User ID and not email address

I am using the Python package rtclcient (v0.6.0) to get info from work item.
Some of the properties I am querying from my RTC work item include:
returned_properties_list = [
"rtc_cm:modifiedBy",
"dc:modified",
"rtc_cm:contextId",
"dc:subject",
"oslc_cm:priority",
"dc:creator",
"rtc_cm:due",
"rtc_cm:estimate",
"rtc_cm:correctedEstimate",
"rtc_cm:timeSpent",
"rtc_cm:startDate",
"dc:created",
"rtc_cm:resolvedBy",
"rtc_cm:plannedFor",
"rtc_cm:ownedBy",
]
When the query for these items finish and I examine the returned variables, I notice that the 'ownedBy' value is the user's id, not their email address.
If I look at the value of raw_data['rtc_cm:ownedBy']['#rdf:resource'] it is a link which goes to that user's profile.
On the profile I can see the same User ID which is being recieved as the 'ownedBy' value.
Also on the profile is the User's E-mail Address. This email address value is what I need, but I can't seem to find a way to query for this value using the rtcclient python package.
I've tried adding "rtc_cm:emailAddress" to my query properties but no luck,
Can anyone help me get the ownedBy user email address for a RTC ticket using the rtcclient package? Thanks
fixed by cloning the rtcclient repo, and adding my own custom function getUserEmail

How to force remove records form lines in odoo?

something wrong happened in account moves as adding an analytic account to journal items of vendor bills and I need to loop on all lines in account moves and remove the analytic account from all lines by this bit of code
class NewModule(models.Model):
_inherit = 'account.move'
def analytic(self):
all=self.env['account.move'].search([('type','=','in_invoice')])
ana=all.line_ids.mapped('analytic_account_id')
ana.unlink()
but when this method run I get this error "The operation cannot be completed: another model requires the record being deleted. If possible, archive it instead.
Model: Analytic Line (account.analytic.line), Constraint: account_analytic_line_account_id_fkey" as image below
otherwise if tried to remove the analytic account for UI it removed without any issues but there is too many bills to do it manually
any help will be appreciated
You are trying to delete analytic_account objects.
You need to remove Many2Many connections to the analytic_account objects.
all=self.env['account.move'].search([('type','=','in_invoice')])
all.write({'analytic_account_id':[(5, 0, 0)]})
It should be like that. But I did not test it.
it's worked for me with this method
def analytic(self):
self.env['account.move'].search([('type', 'in', ('out_invoice', 'in_invoice'))]).line_ids.write({'analytic_account_id':[(5, 0, 0)]})

Replace multiple values in string using replace, sub string and find in Python

So im pulling issues from our jira project and I need to replace url's with new formatted url's in the description.
old description contains the old sharepoint server URL's so I need to change them to our new online Sharepoint url.
I decided to use Python to make use of the atlassian plugin.
here is a version of how the description looks like in the jira issue currently:
Good day
we need a new validation on the External Reference when doing work pads or amending manually when we do refund, it seems that the user that updates this is using Tab or Enter and therefore the payment files fails ,
we need users to be validated while updating refund reference same way as we limited claims payments for updating invoice numbers
thank you
regards
*BRS & FRS:*
[BRS_FRS_PS_ACC_Payments_v20.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
*Sign Offs:*
[BRS_FRS_PS_ACC_Payments_v20.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FPayments%2FV20%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FWorkpads%20%26%20incoming%20payments%2FV5%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
*Technical Documentation:*
N/A
*Unit Testing:*
[TU_dd-1821|http://portal.mycompany.local/mycompany/someproject/SitePages/Home.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FUnit%20Testing&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B5AF02A9E%2D451A%2D443D%2DB8CA%2DAF7C7ED6F00C%7D]
this is how i pulled in the issue from Jira( my plan is to scan through all issues and update.
from jira import JIRA
import re
jira = JIRA(server=('https://mycompanydev.atlassian.net'),basic_auth=('user', 'password'))
issue = jira.issue("S1-3000")
print("Ticket nr: ", issue)
olddescription = issue.fields.description
newdescription = olddescription
So i managed to change the first part of the url with this line:
newdescription = newdescription.replace("http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2F", "https://somecompany.sharepoint.com/sites/CCPortal/")
and this line:
newdescription = newdescription.replace("http://portal.mycompany.local/mycompany/someproject/SitePages/Home.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2F", "https://mycompany.sharepoint.com/sites/CCPortal/")
this code completes successfully and changes the URL as intended.
Now i need to remove the end of the url from the string "View=" and the string "FolderCTID="
my line of code to do this:
newdescription = newdescription.replace(newdescription[newdescription.find("View=")-1:newdescription.find("]")],"")
and:
newdescription = newdescription.replace(newdescription[newdescription.find("FolderCTID="):newdescription.find("]")], "")
for some reason it only does the first 2 URLs:
result looks like this:
Good day
we need a new validation on the External Reference when doing work pads or amending manually when we do refund, it seems that the user that updates this is using Tab or Enter and therefore the payment files fails ,
we need users to be validated while updating refund reference same way as we limited claims payments for updating invoice numbers
thank you
regards
*BRS & FRS:*
[BRS_FRS_PS_ACC_Payments_v20.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS]
*Sign Offs:*
[BRS_FRS_PS_ACC_Payments_v20.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FPayments%2FV20%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FWorkpads%20%26%20incoming%20payments%2FV5%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6]
*Technical Documentation:*
N/A
*Unit Testing:*
[TU_MV-1821|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FUnit%20Testing&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B5AF02A9E%2D451A%2D443D%2DB8CA%2DAF7C7ED6F00C%7D]
as you can see the code removed the first 2 "View=" strings with the trailing string to the end.
I cant figure out where I went wrong I also tried putting this in a while loop and just repeating the code 5 times for a test.
str.find returns the lowest index where the substring is found. So if newdescription has more than one "]", presumably because it contains more than one link, that means the returned index will only be correct for the first link.
str.find also accepts an optional start/end index to limit the search, so you can use the index of "View=" as an offset for the search for "]":
offset = newdescription.find("View=")
replace_me = newdescription[offset:newdescription.find("]", offset)]
newdescription = newdescription.replace(replace_me, "")

How to access cookie and IP fields in DjangoRatings?

I'm using the djangoratings library found here and I have everything running and set up. In my views.py file I have a button which executes this line of code when pushed:
myinstance.rating.add(score=1, user=request.user, ip_address=request.META['REMOTE_ADDR'], request.COOKIES)
Everything works fine. The backend works, my columns are updated with the votes etc etc, but how can I access/call the IP and cookie fields and columns in djangoratings so that I can write a quick if condition that refuses to run the 'add' line if the cookies and IP have already voted?
Thanks in advance for any help. I've been really struggling with this a lot.
myinstance.rating contains method get_ratings() - which returns queryset to calculate all votes related to object. You can easily extend it for retrive necessary information. For example:
# it's lazy object
rating = myinstance.rating.get_ratings()
# do additional query for db
if not rating.filter(user=user, ip_address=request.META['REMOTE_ADDR']).exists():
...

How to force valid properties & values to be set on all files being added/updated in SVN?

Is it possible to force a user who is either committing a change or adding a new file to set valid values for svn:keywords (e.g. Date, Author, & URL)?
It would be great if this behavior could be included in a pre-commit hook, preferably written in python.
check this out:
http://mr-ats.tigris.org/svn/mr-ats/trunk/src/hooks/property-check/
login is: guest /[no password]

Categories