Skip to content

Commit

Permalink
make passing a URL to getLink work
Browse files Browse the repository at this point in the history
  • Loading branch information
benji-york committed Sep 11, 2007
1 parent 0e26a55 commit 11c64ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/zope/testbrowser/real.js
Expand Up @@ -61,7 +61,7 @@ function tb_get_link_by_predicate(predicate, index) {
var i=0;
var found = null;
if (index == undefined) index = null;
for (x=0; x < anchors.length; x++) {
for (var x=0; x < anchors.length; x++) {
a = anchors[x];
if (!predicate(a)) {
continue;
Expand Down Expand Up @@ -96,17 +96,17 @@ function tb_get_link_by_text(text, index) {
}, index)
}

function tb_get_link_by_id(id, index) {
function tb_get_link_by_url(url, index) {
return tb_get_link_by_predicate(
function (a) {
return a.id == id;
return a.href.indexOf(url) == 0;
}, index)
}

function tb_get_link_by_url(url, index) {
function tb_get_link_by_id(id, index) {
return tb_get_link_by_predicate(
function (a) {
return a.href.indexOf(url) == 0;
return a.id == id;
}, index)
}

Expand Down
2 changes: 1 addition & 1 deletion src/zope/testbrowser/real.py
Expand Up @@ -157,7 +157,7 @@ def getLink(self, text=None, url=None, id=None, index=None):
% (simplejson.dumps(text), js_index))
elif url is not None:
msg = 'url %r' % url
token = self.execute('tb_get_link_by_text(%s, %s)'
token = self.execute('tb_get_link_by_url(%s, %s)'
% (simplejson.dumps(url), js_index))
elif id is not None:
msg = 'id %r' % id
Expand Down
3 changes: 2 additions & 1 deletion src/zope/testbrowser/real.txt
Expand Up @@ -28,4 +28,5 @@
>>> browser.getLink('Preferences')
<Link text='Preferences' url='http://images.google.com/preferences?hl=en'>

# >>> browser.getLink(url='http://news.google.com')
>>> browser.getLink(url='http://news.google.com/')
<Link text='News' url='http://news.google.com/nwshp?tab=in'>

0 comments on commit 11c64ef

Please sign in to comment.