Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dk.mehmedbasic
- import java.net.URL
- import java.util.concurrent.TimeUnit
- import org.openqa.selenium.remote.{BrowserType, DesiredCapabilities, RemoteWebDriver}
- import org.openqa.selenium.support.ui.Select
- import org.openqa.selenium.{By, Platform, WebDriver}
- object Test {
- var driver: WebDriver = null
- def main(args: Array[String]) {
- setupWebDriver()
- driver.navigate().to("http://www.myprotein.com/sports-nutrition/impact-whey-protein/10530943.html")
- val list = driver.findElements(By.className("locale-overlay"))
- val overlay = if (list.isEmpty) {
- null
- } else {
- list.get(0)
- }
- if (overlay != null && overlay.isDisplayed) {
- overlay.findElement(By.id("button2")).click()
- }
- val select = new Select(driver.findElement(By.id("opts-7")))
- select.selectByIndex(1)
- println(driver.findElement(By.className("product-price")).getText())
- }
- def setupWebDriver() {
- val caps: DesiredCapabilities = new DesiredCapabilities()
- caps.setJavascriptEnabled(true)
- caps.setBrowserName(BrowserType.GOOGLECHROME)
- caps.setPlatform(Platform.LINUX)
- //driver = new PhantomJSDriver(caps)
- driver = new RemoteWebDriver(new URL("http://localhost:9515"), caps)
- driver.manage.timeouts.implicitlyWait(10, TimeUnit.SECONDS)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement