Dojo/Dijit: Can't get filtering select to work - dojo

I have a page with some JavaScript and it includes dojo.parser and has parseOnLoad set to true and whatnot.
Later in the page, I have another JavaScript tag that has:
dojo.require('dijit.form.FilteringSelect');
dojo.registry.remove('ID OF SELECT BOX');
After all that, I have a select box with dojoType="dijit.form.FilteringSelect".
Whenever I load the page, I get:
undefined Could not load class 'dijit.form.FilteringSelect'. Did you spell the name correctly and use a full path, like 'dijit.form.Button'?
Any ideas why? If I put the require statement in the first JavaScript tag, it works (but that tag is in a more global file, so I don't want it there).

dojo.registry is not correct. we have only dijit.registry.remove function. Maybe that is causing the problem.

Related

I can't extract the links with scrapy

i need help for extract the links in the page: https://www.remax.pt/comprar-empreendimentos?searchQueryState={%22page%22:1,%22sort%22:{%22fieldToSort%22:%22PublishDate%22,%22order%22:1}}
You could shorten it, you don't have to target from the top element to your target. It's easier to debug then.
response.css('div.developments-search-details-component a::attr(href)').get()
You can change this to Xpath if you prefer that. But usually when you try to target an element and it returns null or empty list it's because of a typo or because that element is dynamically rendered after page load.
To debug I'll usually start at a higher element in the tree and see if that exists.
In this case you could try:
response.css('div.developments-search-details-component').get()
first and see if that works.

How to find an element containing #nbsp; in text?

I've an element with html -
<h3>App-1 Playground Login</h3>
I want to identify it with entire text - App-1 Playground Login, but causing issues to identify it. Please help how this element can be identified.
Please use the below xpath. I have already tested that and it is working fine. In the second argument of the translate method you need to type "ALT+0160" and in the third argument you will have to put just a normal space.
//h3[contains(translate(text(),' ',' ' ), 'App-1 Playground Login')]
One of the way to select your title could be :
//h3[text()= concat('App-1 Playground',codepoints-to-string(160),'Login')]
Works fine on http://xpather.com/

Dynamic xpath handling

Below is my xpath
driver.findElement(By.xpath("html/body/div[9]/div/a/div")).click();
In above code value of div[6] is keep changing.
Sometimes it will
driver.findElement(By.xpath("html/body/div[6]/div/a/div")).click();
or
driver.findElement(By.xpath("html/body/div[1]/div/a/div")).click();
Please provide solution.
We faced this issue with dynamic page content making XPath identification basically useless. We took the decision to make sure everything that needed to be identified in a test would have an id set. So:
driver.findElement(By.xpath("html/body/div[6]/div/a/div")).click();
becomes:
driver.findElement(By.id("myDivId")).click();
Use div 'id' or 'class' instead of div[6].
like:
/html/body/div[#id='div_id']/div/a/div
(or)
/html/body/div[#class='div_className']/div/a/div

QTP - Checking dynamic pages

I'm trying to check if a value is contained in the innertext of a webelement but I'm having a little problem: frames seem to change at every refresh of the pages.
These are the steps I've recorded:
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebEdit("pdrBean.pdrPod").Set parameter("POD")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebButton("Cerca").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_2").Image("show_files").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_6").Image("Lente").Click
cctype = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down").GetROProperty("innertext")<br>
DataAct = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down_2").GetROProperty("innertext")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click
The frames "dme2_appl6" and "dme2_appl7" changes at every refresh of the two pages.
The question is simple: how can I rewrite these two actions to make them universal?
I've tried to do something like:
Set objFrame = Frame("title:=dme2_appl_.")
and then
Browser("SystemPage").Page("SystemP").objFrame.Image("Lente").Click
But QTP gives me an error in return: "property or method not supported by the object"
Please try using the below code
Browser("SystemPage").Page("SystemP").Image("Lente").Click
Avoid using the "Frame" and if you really want to use it, put regex for name property of Frame.
Go to Object Properties--> Click on the Frame object --> Mandatory Properties--> Change name property as
like iFrame_213123123 to i.*
Hope this will solve your problem.
I don't think you can use a frame object that way. When you write Page().Frame() UFT sets the frame's parent in different way than if you first create the Frame.
Think of Frame() as a function that behaves differently when called on a Page or as a free function.
Try:
Browser("SystemPage").Page("SystemP").Frame("title:=dme2_appl_.")

web2py SQLFORM accepting too fast

I have a web2py SQLFORM that gets generated and returned by an AJAX call and the form is put in a DIV I defined.. I want that SQLFORM to be an update form, not an insert form. The problem is the form immediately runs it's accept function once it is written to that DIV. This doesn't happen if the form is for inserting, only updating. That initial accept fails and hitting the submit button does not allow for a second accept.
I don't know why the accept fails or why it happens immediately.
heres the JavaScript function that makes the AJAX call
function displayForm(currID){
//Remove everything from the DIV we want to use
$('#window').empty();
//Call the ajax to bring down the form to update the series
ajax('{{=URL('newForm')}}/'+currID,
[], 'window');
}
And here is the newForm controller
def newSerForm():
record = db.myTable(request.args[0])
form = SQLFORM(db.myTable, record, fields=['series_name','image_thumbnail'])
if form.accepts(request.vars,session):
print 'Series update successful!'
else:
print 'Series update Failed...'
return form
displayForm is fired by clicking a button and once you do the form accepts and fails and the submit button doesn't work again. Is there a way to make an SQLFORM do this? The weird thing is if I change this to make inserts into myTable, it works fine. It behaves exactly as it should. But doing it this way doesn't work.
Ok now this is where it gets weird.
I tried to achieve the same functionality here with a totally different approach, an iFrame. I made new functions in my controllers that create the form based on request.args[0]. looks like this
def editEntry():
print request.args[0]
record = db.myTable(request.args[0])
form = SQLFORM(db.CC_user_submission, record, fields=['series_name', 'image_thumbnail']).process()
return dict(form=form)
And then a corresponding HTML page that just displays form. What could be simpler right? I go to that page based on a link that gives the correct argument. Take me to a page with a form for updating. Updating works perfect. Great, now lets put it in an iFrame instead of linking to it. I put it in an iFrame on the original page. Open up the iFrame. Doesn't work. I have no idea what is going is there any part of an explanation to this?
By using the iFrame method I actually got this one to work. Since it required an iFrame to be appended with jQuery which needs quotes and the iFrame URL which also needs quotes, the notation got pretty confusing but it's doable. Looked like this:
var myURL = "{{=URL('editEntry')}}/"+idArg.toString();
$('#window').append("<iframe src = " + myURL + " width='450' height='400'> </iframe>");
It's not pretty but it works.