Skip to content

Commit

Permalink
solution for 2.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Marohn Howard committed May 20, 2022
1 parent d3d9e52 commit ed0f65a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 2.7-Solution/SpecPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { By, WebDriver, until} from "selenium-webdriver";


export class SpecPage {
driver: WebDriver;

url: string = "https://www.google.com";

searchBar: By = By.name('q')
results: By = By.id("rso")

constructor(driver: WebDriver) {
this.driver = driver;
}

async navigate() {
await this.driver.get(this.url)
await this.driver.wait(until.elementLocated(this.searchBar))
}
async sendKeys(elementBy: By, keys) {
await this.driver.wait(until.elementLocated(elementBy))
return this.driver.findElement(elementBy).sendKeys(keys)
}
async getText(elementBy: By) {
await this.driver.wait(until.elementLocated(elementBy))
return (await this.driver.findElement(elementBy)).getText()
}
async doSearch(text: string) {
return this.sendKeys(this.searchBar, `${text}\n`)
}
async getResults() {
return this.getText(this.results)
}
}

0 comments on commit ed0f65a

Please sign in to comment.