- https://stackoverflow.com/questions/16952514/selenium-webdriver-findelementby-xpath-not-working-for-me
- http://www.guru99.com/xpath-selenium.html
- http://asynchrony.blogspot.com.au/2008/11/enter-key-press-in-selenium.html
- https://stackoverflow.com/questions/1629053/typing-enter-return-key-in-selenium
- https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebElement.html#sendKeys-java.lang.CharSequence...-
- https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#findElement-org.openqa.selenium.By-
What I needed:
- Download selenium-java-3.4.0.jar and realise the internal jar file was now renamed to client-combined-3.4.0-nodeps.jar
- Download the ChromeDriver as well
- To run from a command line, I needed to create the following batch file:
@echo off
setLocal EnableDelayedExpansion
set CLASSPATH="
for /R c:\u\selenium-java-3.4.0\lib %%a in (*.jar) do (
set CLASSPATH=!CLASSPATH!;%%a
)
set CLASSPATH=!CLASSPATH!"
c:\tibco\tibcojre64\1.8.0\bin\java -Xmx256M -Xms32M -noverify -cp lib\kotlin-preloader.jar org.jetbrains.kotlin.preloading.Preloader -cp lib\kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -cp c:\u\joda-time-2.9.jar;c:\u\selenium-java-3.4.0\client-combined-3.4.0-nodeps.jar;!CLASSPATH!
- I reached as far as the following:
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.By
import org.openqa.selenium.Keys
System.setProperty("webdriver.chrome.driver", "c:/u/chromedriver.exe")
val chdr = ChromeDriver()
val HOST = "https://<<REDACTED>>/"
chdr.get(HOST)
chdr.findElement(By.id("login_username")).sendKeys("<<REDACTED>>")
chdr.findElement(By.id("login_password")).sendKeys("<<REDACTED>>", Keys.ENTER)
chdr.findElement(By.partialLinkText("Your account")).click()
chdr.get(HOST + "your-super/super/investments/your-investments/")
chdr.get(HOST + "your-super/super/insurance/your-insurance/")
chdr.get(HOST + "your-super/super/account-history/transactions/")
chdr.get(HOST + "your-super/super/account-history/request-history/")
// Here's how I eventually navigated the dropdown menu
chdr.findElement(By.linkText("Money Map")).click()
chdr.findElement(By.id("main")).findElement(By.tagName("input")).click()
chdr.findElement(By.linkText("Your account")).click()
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Super']")).sendKeys(Keys.ENTER)
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Account history']")).sendKeys(Keys.ENTER)
chdr.findElement(By.linkText("Statements")).click()
chdr.findElement(By.linkText("Your account")).click()
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Insurance']")).sendKeys(Keys.ENTER)
chdr.findElement(By.linkText("Your Insurance")).click()chdr.findElement(By.linkText("Your account")).click()
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Super']")).sendKeys(Keys.ENTER)
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Insurance']")).sendKeys(Keys.ENTER)
chdr.findElement(By.linkText("Your Insurance")).click()
chdr.findElement(By.linkText("Your account")).click()
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Add to super']")).sendKeys(Keys.ENTER)
chdr.findElement(By.xpath("//*[@data-ec-expand='Expand Advice']")).sendKeys(Keys.ENTER)
chdr.findElement(By.linkText("Money Map")).click()
chdr.findElement(By.linkText("Your account")).click()
chdr.findElement(By.linkText("Notifications")).click()
chdr.findElement(By.linkText("Money Map")).click()
chdr.findElement(By.partialLinkText("Logout")).click()
No comments:
Post a Comment
Note: only a member of this blog may post a comment.