I'm working on a project in IntelliJ that uses PhantomJS and Selenide to automate web browsing activity. To run Javascript commands, we use the executeJavascript() method in our Java code. We call this method many times in our code to execute the Javascript commands that we want.
For this particular case, we are making a program that should automatically log us into Footlocker.
Code for program:
public Boolean doInBackground() {
WebDriver driver = getWebDriver();
System.out.println("Running Footlocker");
open(account.getEarlyLink()); //opens URL
System.out.println("Running Footlocker");
if (!loggedIn) {
WebDriverRunner.setWebDriver(driver);
$("#guest_welcome_login").shouldBe(visible).click();
$("#login_container").shouldBe(visible);
}
executeJavaScript("$('html').find('iframe').eq(1).contents().find('#login_email').val('%s')", account.getUsername());
executeJavaScript(String.format("$('html').find('iframe').eq(1).contents().find('#login_password').val('%s')", account.getPassword()));
executeJavaScript("$('html').find('iframe').eq(1).contents().find('button.button.cta_button').click()");
$("#member_welcome").shouldBe(visible);
}
When we run the program, none of the executeJavascript() commands are actually executed, but when we run each command one by one in the IntelliJ expression executer (in the debugger), they work.
Anyone know what's happening here?