package org.callimachusproject.webdriver.pages;

import org.callimachusproject.webdriver.helpers.WebBrowserDriver;
import org.openqa.selenium.By;

public class DigestUserEdit extends CalliPage {

	public DigestUserEdit(WebBrowserDriver driver) {
		super(driver);
	}

	public FileUploadForm openPhotoUpload() {
		driver.click(By.cssSelector("#photo label.control-label a"));
		driver.waitForScript();
		driver.focusInFrame("photo");
		driver.waitForScript();
		final DigestUserEdit edit = this;
		return new FileUploadForm(driver) {
			@Override
			public DigestUserEdit uploadAs(String fileName) {
				driver.click(By.id("upload"));
				driver.focusInFrame("photo", "save-as___");
				driver.type(By.id("label"), fileName);
				driver.focusInFrame("photo");
				driver.click(By.xpath("(//button[@type='button'])[2]"));
				return edit;
			}
		};
	}

	public CalliPage save() {
		driver.click(By.id("save"));
		return page();
	}

}

@@ -866,24 +866,53 @@
 ge save() %7B%0A
+%09%09driver.focusInTopWindow();%0A
 %09%09driver.cli

Switch focus back to top window