amohanta / spynner

Automatically exported from code.google.com/p/spynner
GNU General Public License v3.0
0 stars 0 forks source link

Variable name length problem #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am working on a site with too long variable names. There are two <select> 
fields on this side, one is:

<select name="ctl00$plSearch$dblBolge$dblBolge_DropDownList1" 
id="ctl00_plSearch_dblBolge_dblBolge_DropDownList1"  
...... >

and the other is:

<select name="ctl00$plSearch$dblBolge$dblBolge_DropDownList2" 
id="ctl00_plSearch_dblBolge_dblBolge_DropDownList2"
...... >

So when I try to select an option from the first one, there is no problem, but 
when I try to select an option from the second one using it's id or name, it 
still selects from the first one instead. As can be seen from the html tags, 
both their names and ids are the same until the last character, so I guess that 
this is a problem about maximum number of significant characters in variable 
names. How can I overcome this situation?   

Original issue reported on code.google.com by akcali.ozgur on 14 Jul 2011 at 6:46

GoogleCodeExporter commented 9 years ago
How do you do the select? I made a quick test using pyquery and it worked fine:

d = pyquery.PyQuery(html)
print d('#ctl00_plSearch_dblBolge_dblBolge_DropDownList1')
...
print d('#ctl00_plSearch_dblBolge_dblBolge_DropDownList2')

(note that development of this package has moved to github)

Original comment by tokland on 14 Jul 2011 at 8:58

GoogleCodeExporter commented 9 years ago
Actually, I have just found out that problem was something different, I was 
trying to select from a wrong <select>, and solved it now. However, there is 
still something I don't understand.

I do the selects as follows (br is a spynner.Browser object here):

br.select("id=ctl00_plSearch_dblBolge_dblBolge_DropDownList1, option[value=70]")

br.select("id=ctl00_plSearch_dblBolge_dblBolge_DropDownList2, option[value=70]")

The second select has no option with a value 70 on the site, however, when I 
run the second select, it selects the option with value 70 from the first 
select, even though I provided the second select's id. What could be the reason 
for this?

Original comment by akcali.ozgur on 14 Jul 2011 at 10:06

GoogleCodeExporter commented 9 years ago
try directly in chrome, Browser#select is nothing more than a Jquery call:

    def select(self, selector):        
        """Choose a option in a select using a jQuery selector."""
        jscode = "%s('%s').attr('selected', 'selected')" % (self.jslib, selector)
        self._runjs_on_jquery("select", jscode)

what happens if you run this in the JS console

Original comment by tokland on 14 Jul 2011 at 10:55