constructor( driver, url = 'https://jetpack.com/' ) { super( driver, By.css( '.logo[title="Jetpack"]' ), url ); }
addNewTag( tag ) { const tagEntrySelector = By.css( 'input.token-field__input' ); driverHelper.waitForFieldClearable( this.driver, tagEntrySelector, this.explicitWaitMS ); return this.driver.findElement( tagEntrySelector ).sendKeys( tag + '\n' ); }
trashPost() { driverHelper.clickWhenClickable( this.driver, By.css( '.post-editor__sidebar button.editor-delete-post' ) ); return driverHelper.clickWhenClickable( this.driver, By.css( '.dialog button.is-primary' ) ); }
driver.wait(function() { return driver.isElementPresent(webdriver.By.id('display')); }, 1000);
launchPreview() { return driverHelper.clickWhenClickable( this.driver, By.css( 'button.editor-ground-control__preview-button' ), this.explicitWaitMS ); }
then('I see a link to "$href"', async function(href) { await driver.findElement(By.css('a[href="' + href + '"]')) })
driver.wait(function() { return driver.isElementPresent(webdriver.By.id('newNote')); }, 10000);
var webdriver = require('selenium-webdriver'); var driver = new webdriver.Builder(). withCapabilities(webdriver.Capabilities.chrome(). set('log.driver', webdriver.logging.LevelName.DEBUG) ).build(); driver.get('http://localhost:8080/form.html'); var promise = driver.sleep(1000); // Just for instructional purposes so you can see it working. // Example of asynchronous debug logging. promise.then(function () { console.log('After Sleep'); } ); driver.findElement(webdriver.By.id('field1')).sendKeys('some random text'); // Click the submit button driver.findElement(webdriver.By.id('button1')).click(); waitUntilVisible(driver, '//a[text()="Page 2"]'); waitUntilVisible(driver, '//span[text()="some random text"]').then(function() { console.log('SUCCESS!'); }); // Go to Page 2 driver.findElement(webdriver.By.xpath('//a[text()="Page 2"]')).click(); waitUntilVisible(driver, '//h2[text()="This is Page 2"]'); // Another unnecessary delay to slow it down for learning purposes. driver.sleep(3000);
it('can see the example repo on GitHub', async () => { await driver.get('http://github.com/gleneivey/mocha-node-webdriver.git'); const elements = await driver.findElements(By.css('.octicon.octicon-git-pull-request')); expect(!!elements.length).toEqual(true); });
async congratulationsExists() { return await this.driver.findElement( By.css( '.checklist-onboarding-welcome' ) ); }
constructor( driver ) { super( driver, By.css( '.inline-help__onboarding' ) ); }
it('should contain Inspector monitor\'s component', async () => { const val = await this.driver.findElement(webdriver.By.xpath('//div[contains(@class, "inspector--jss-")]')) .getText(); expect(val).toExist(); });
it('should contain INIT action', async () => { const val = await this.driver.findElement(webdriver.By.xpath('//div[contains(@class, "actionListRows--jss-")]')) .getText(); expect(val).toMatch(/@@INIT/); });
it('should have Redux DevTools UI on current tab', async () => { await this.driver.switchTo().frame( this.driver.findElement(webdriver.By.xpath(`//iframe[@src='${devPanelPath}']`)) ); await delay(1000); });
driver.get(url).then(function() { return driver.findElement(webdriver.By.css(registerSelector)); }).then(function(link) {
driver.get(url).then(function() { return driver.findElement(webdriver.By.css(prospectusSelector)); }).then(function(link) {
then('I see $n links below the heading', async function(n) { let array = await driver.findElements(By.css('h1 + ul a')) expect(array).to.have.length(+n) })
}).then(function() { return driver.findElement(webdriver.By.css(`#${emailInputId}:invalid`)); }).then(function(invalid) {
field: name => By.css(`.aor-field-${name} > div > span`),
}).then(function() { driver.findElement(webdriver.By.css(`#${policyCheckboxId}:invalid`)); }).then(function(invalid) {
driver.wait(function() { return driver.isElementPresent(webdriver.By.id('pageflip')); }, 10000);
driver.get(url).then(function() { return driver.findElement(webdriver.By.id(emailInputId)); }).then(function(email) {
driver.executeScript('$("#actions").css("display", "block");').then(function() { driver.findElement(webdriver.By.xpath('//paper-icon-button[@icon="close"]')).click(); });
}).then(function() { return driver.findElement(webdriver.By.id(policyCheckboxId)); }).then(function(policy) {
getCategoriesAndTags() { const categoriesAndTagsSelector = By.css( '.editor-categories-tags__accordion span.accordion__subtitle' ); return this.driver.findElement( categoriesAndTagsSelector ).getText(); }
}).then(function() { return driver.findElement(webdriver.By.id(newsletterSubmitId)); }).then(function(button) {
publicizeToTwitterAccountDisplayed() { const twitterAccountSelector = By.xpath( `//h5[text()='Twitter']/..//label` ); this.driver.wait( until.elementLocated( twitterAccountSelector ), this.explicitWaitMS, 'Could not locate a twitter account configured to share' ); return this.driver.findElement( twitterAccountSelector ).getText(); }
driver.get(url).then(function() { return driver.findElement(webdriver.By.css(conferenceSelector)); }).then(function(link) {
waitForIsPendingStatus() { return this.driver.wait( until.elementLocated( By.css( '.editor-status-label.is-pending' ) ), this.explicitWaitMS, 'Could not see the pending status in the specified time' ); }
async present(buttonId) { await this.navigate('#basic'); this.driver.findElement(By.id(buttonId)).click(); await this.driver.wait(until.elementLocated(By.css('.popover-wrapper'))); return await this.driver.wait(until.elementIsVisible(this.driver.findElement(By.css('.popover-wrapper')))); }