Skip to content

Instantly share code, notes, and snippets.

@stuncloud
Last active April 25, 2016 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuncloud/768c2d8a2f3cf1732d34d5cfe155d1a8 to your computer and use it in GitHub Desktop.
Save stuncloud/768c2d8a2f3cf1732d34d5cfe155d1a8 to your computer and use it in GitHub Desktop.
Selenium Basic + UWSC でポップアップをよろしくする
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>popup1</title>
<script type="text/javascript">
var openPopup = function(name) {
var feature = 'left=100'
+ ',top=100'
+ ',height=200'
+ ',width=300'
+ ',menubar=false'
+ ',toolbar=false'
+ ',location=false';
console.log(feature)
var child = window.open('popup2.html', name, feature);
return child;
}
</script>
</head>
<body>
<input type="button" id="openPopup" value="open popup" onclick="openPopup();">
<a href="popup2.html" target="_blank" id="openNewWindow">popup2</a>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>popup2</title>
</head>
<body>
<div id="message">( ‘(I¥‘))</div>
</body>
</html>
driver = createoleobj("Selenium.ChromeDriver")
driver.Start()
driver.Get("http://test/popup1.html")
button = driver.FindElementById("openPopup") // ポップアップ
//button = driver.FindElementById("openNewWindow") // 別ウィンドウ
button.Click()
driver.SwitchToWindowByTitle("popup2")
text = driver.FindElementById("message").Text
msgbox(text)
driver.Quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment