def test_finding_text_works_accross_non_text_blocks(self): s = self.selenium self.add_article() transaction.abort() co = list(IWorkingcopy(None).values())[0] paragraph = co.body.create_item('p') paragraph.text = 'foo bar baz' co.body.create_item('image') paragraph = co.body.create_item('p') paragraph.text = 'foo baz' transaction.commit() s.refresh() para = 'css=.block.type-p .editable p' s.waitForElementPresent(para) self.eval('document.querySelector("%s").scrollIntoView()' % para.replace('css=', '')) s.clickAt(para, '5,5') s.waitForElementPresent('xpath=//a[@href="show_find_dialog"]') click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'baz') s.click('jquery=button:contains(Weiter)') self.wait_for_condition( 'window.getSelection().getRangeAt(0).startOffset == 8') s.click('jquery=button:contains(Weiter)') self.wait_for_condition( 'window.getSelection().getRangeAt(0).startOffset == 4')
def test_finding_text_case_insensitive(self): s = self.selenium self.add_article() self.create("<p>FOO bar foo</p>") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'fOo') s.click('jquery=button:contains(Weiter)') self.wait_for_condition( 'window.getSelection().getRangeAt(0).startOffset == 0')
def test_replacing_all(self): s = self.selenium self.add_article() self.create("<p>foo bar baz</p>") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'foo') s.type('id=find-dialog-replacement', 'qux') s.click('jquery=button:contains(Alles ersetzen)') s.waitForAlert('1 Stelle(n) ersetzt.') s.waitForText('css=.block.type-p p', 'qux bar baz')
def test_replacing_single_match(self): s = self.selenium self.add_article() self.create("<p>foo bar baz</p>") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'foo') s.type('id=find-dialog-replacement', 'qux') s.click('jquery=button:contains(Weiter)') s.click('jquery=button:contains(Ersetzen)') self.assertEqual('qux bar baz', s.getText('css=.block.type-p p'))
def test_stops_wrapping_if_nothing_found_since_last_wrap(self): s = self.selenium self.add_article() self.create("<p>foo bar foo</p>") self.execute( "zeit.content.article.select(" "window.jQuery('.block.type-p .editable p')[0].firstChild, " "4, 4)") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'baz') s.click('jquery=button:contains(Weiter)') s.waitForConfirmation( 'Das Textende wurde erreicht. Suche am Textanfang fortsetzen?') s.waitForAlert('Keine weiteren Ergebnisse.')
def test_asks_for_confirmation_to_wrap_around_at_beginning(self): s = self.selenium self.add_article() self.create("<p>foo bar foo</p>") self.execute( "zeit.content.article.select(" "window.jQuery('.block.type-p .editable p')[0].firstChild, " "4, 4)") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'foo') s.click(u'jquery=button:contains(Zurück)') s.click(u'jquery=button:contains(Zurück)') s.waitForConfirmation( 'Der Textanfang wurde erreicht. Suche am Textende fortsetzen?') self.wait_for_condition( 'window.getSelection().getRangeAt(0).startOffset == 8')
def test_closes_replace_dialog_on_cancelled_wrapping_confirmation(self): s = self.selenium self.add_article() self.create("<p>foo bar foo</p>") self.execute( "zeit.content.article.select(" "window.jQuery('.block.type-p .editable p')[0].firstChild, " "4, 4)") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'foo') s.click('jquery=button:contains(Weiter)') s.click('jquery=button:contains(Weiter)') confirmation = s.selenium.switch_to_alert() self.assertEqual( 'Das Textende wurde erreicht. Suche am Textanfang fortsetzen?', confirmation.text) confirmation.dismiss() s.waitForNotVisible('id=find-dialog-searchtext') self.wait_for_condition( 'window.getSelection().getRangeAt(0).startOffset == 8')
def test_saves_if_replacing_ends_in_subsequent_editable(self): from zeit.content.article.article import Article from zeit.content.article.interfaces import IArticle wl = zope.component.getUtility( zeit.cms.tagging.interfaces.IWhitelist) self.repository['article'] = Article() with checked_out(self.repository['article']) as co: zeit.cms.content.field.apply_default_values( co, IArticle) co.year = 2010 co.ressort = u'International' co.title = 'foo' co.keywords = ( wl.get('testtag'), wl.get('testtag2'), wl.get('testtag3'),) paragraph = co.body.create_item('p') paragraph.text = 'foobar' paragraph = co.body.create_item('image') paragraph = co.body.create_item('p') paragraph.text = 'foobaz' self.open('/repository/article/@@checkout') s = self.selenium s.waitForElementPresent('css=.block.type-p .editable p') s.click('css=.block.type-p .editable p') self.execute( "zeit.content.article.select(" "window.jQuery('.block.type-p .editable p')[0].firstChild, " "0, 0)") click(s, 'xpath=//a[@href="show_find_dialog"]') s.waitForElementPresent('id=find-dialog-searchtext') s.type('id=find-dialog-searchtext', 'foo') s.type('id=find-dialog-replacement', 'qux') s.click('jquery=button:contains(Weiter)') s.click('jquery=button:contains(Ersetzen)') s.click('jquery=button:contains(Weiter)') s.click('jquery=button:contains(Ersetzen)') s.click('css=.find-dialog button.ui-dialog-titlebar-close') s.click('css=.wired') s.waitForTextPresent('quxbar') s.waitForTextPresent('quxbaz')