I introduced Selenium because the on-site team I was seconded to manually created test data on the screen. Since the system I am in charge of works only with IE, I do not make test cases with IDE I implemented the case in java using WebDriver and operated the browser. It also serves as a memorandum and summarizes problems and usage.
windows10 64bit IE11 java 1.8.0_121 eclipse Neon.2 Release (4.6.2) selenium 2.53.1
Create a new maven project in eclipse Check "Create a simple project" when creating
Modify pom.xml
pom.xml excerpt
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
</dependencies>
How to write IEDriver initial settings
System.setProperty("webdriver.ie.driver","C:\\Any place\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
Here is a reference for how to use the driver
python
Unexpected error launching Internet Explorer.
Protected Mode must be set to the same value (enabled or disabled) for all zones.
IE browser Internet Options → Security tab settings → Make the protection mode setting the same for all zones
Sendkeys for entering browser text is unusually slow to use I have not investigated the detailed cause, but it seems to be the case when using the 64-bit version of IEDriverServer.
It seems to occur occasionally in IE. I was able to avoid it with the following description.
python
WebElement element = driver.findElement(clickTarget);
element.sendKeys(Keys.CONTROL);
element.click();
Or
new Actions(driver).click(element).build().perform();
Pop-up (notification bar) that appears when you download a file in IE When that happens, selenium will stop. It doesn't work even if I click it manually. With IE11, I couldn't change the settings from the browser. Therefore, create a child thread and leave the download process to that. The parent thread is working hard to keep the main processing going.
Tips
When the parent screen creates a child screen with JS How to do when you want to focus on the sub screen and operate it.
python
//Hold parent window information
String currentHandle = driver.getWindowHandle();
//Switch focus to child window
Set<String> windowHandles = driver.getWindowHandles();
for (String handle : windowHandles) {
if (!handle.equals(currentHandle)) {
driver.switchTo().window(handle);
}
}
//Return to parent when child window processing is finished
driver.switchTo().window(currentHandle);
After ordering an operation with Selenium, I want to wait until it finishes. For example, after searching, I want to perform the following operation after the search is completed and the list appears. The following sources wait for the element with id list to appear on the screen. The timeout is 10 seconds, and an exception occurs when it is exceeded.
python
//Standby object
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(
ExpectedConditions.presenceOfElementLocated(
By.id("list")
)
);
python
WebElement element = driver.findElement(By.xpath("//input[@type='file']"));
element.sendKeys("./File.txt");
https://donow.jp/skillup/?p=776#i-7 http://qiita.com/tukiyo3/items/44f5b64cf222d9da1b5b http://bokuibi.blogspot.jp/2012/05/selenium-2.html http://qiita.com/nkns165/items/53d1afc17023d9ae3ebd
Recommended Posts