这可能是一个java noob问题,但这是我的场景:
我目前将getBodyText()存储为String,这里是代码:
String stored_report = selenium.getBodyText();
File f = new File("C:/folder/" + "report" + ".html");
FileWriter writer = new FileWriter(f);
writer.append(stored_report);
System.out.println("Report Created is in Location : " + f.getAbsolutePath())
writer.close();
Run Code Online (Sandbox Code Playgroud)
我必须使用FileReader吗?我需要做什么才能保存的html文件仍显示html格式?(目前因为它存储为一个字符串,所以页面显示所有内容都显示在一行上)
提前致谢!
每次我通过Selenium RC启动一个Firefox实例时,我都会得到3个不需要出现的窗口:
附加组件窗口通知我"已经安装了3个新的附加组件"(因为我正在使用Selenium的自定义配置文件,它显然添加了DocumentReadyState,KillFF和Selenium RC Runner附加组件)
双窗口有两个以chrome开头的标签://src/content/RemoteRunner.html?sessionId = ...每个
我不需要任何这些是可见的,每次我必须手动关闭附加组件窗口,以最小化其他两个窗口,并最大化Selenium控制的主浏览器窗口.经过这么多次,我很生气,寻求解决方案:
有没有办法自动关闭附加组件窗口并最小化其他两个窗口?
顺便说一句,我在OS X上,所以我也很欣赏一些替代解决方案,它通过操作系统自动化,而不是直接使用Selenium.
我以编程方式创建测试帐户,然后立即尝试使用selenium驱动的浏览器登录.不幸的是,浏览器只是重定向到Facebook主页.我可以简单地看一下在重定向闪存之前看起来是正确的URL,所以我没有理由相信浏览器没有进入我想要的地方.
也就是说,如果创建一个假帐户,然后只需将login_url粘贴到浏览器中,一切正常.任何人都知道为什么在这里使用Selenium可能是独一无二的?有什么我需要做的准备浏览器的https连接或任何东西?
我所做的就是:(使用capybara和Selenium网络驱动程序)
访问@ fake_user.login_url
https://www.facebook.com/platform/test_account_login.php?user_id=100002152974488&n=ILRvb8Lqf2cq05t
GET /platform/test_account_login.php?user_id=100002152974488&n=ILRvb8Lqf2cq05t HTTP/1.1主机:www.facebook.com用户代理:Mozilla/5.0(Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15 )Gecko/20110303 Firefox/3.6.15接受:text/html,application/xhtml + xml,application/xml; q = 0.9,/ ; q = 0.8 Accept-Language:en-us,en; q = 0.5 Accept-Encoding :gzip,deflate Accept-Charset:ISO-8859-1,utf-8; q = 0.7,*; q = 0.7 Keep-Alive:115连接:keep-alive
HTTP/1.1 302找到缓存控制:私有,无缓存,无存储,必须重新验证到期:周六,2000年1月1日00:00:00 GMT位置:http://www.facebook.com/ P3P:CP ="Facebook没有P3P政策.在这里了解原因:http://fb.me/p3p"Pragma:no-cache Set-Cookie:datr = d3J_TWSAN5uIXyh94O1YJkJ8; 到期=星期四,2013年3月14日14:06:47 GMT; 路径= /; 域= .facebook.com; httponly Set-Cookie:lsd = -Lv-N; 路径= /; domain = .facebook.com Content-Type:text/html; charset = utf-8 X-Powered-By:HPHP X-FB-Server:10.52.145.67 X-Cnection:close日期:2011年3月15日星期二14:06:47 GMT
请参阅随附的屏幕截图.
当我将鼠标悬停在以下代码上时:
selenium.waitForPageToLoad("30000");
Run Code Online (Sandbox Code Playgroud)
我收到这条消息:
*void com.thoughtworks.selenium.Selenium.waitForPageToLoad(String arg0)
注意:此元素既没有附加源也没有附加Javadoc,因此找不到Javadoc.*
F3正在给我" 未找到来源 ".
有谁知道从哪里获取这个源(它叫什么)以及如何附加到Eclipse?

我正在尝试-browserSessionReuse Selenium模式来加速我的测试,但我注意到了一个奇怪的行为.
这种模式的目的是避免在测试之间浪费时间打开浏览器,这就是它的工作原理.但并非总是如此,如果我连续运行测试,它们会在同一个浏览器中运行,这是正确的.但是如果在每次测试运行之间经过几分钟,它将忘记它已经打开了一个浏览器并打开一个新的浏览器.
我想丢弃"旧"浏览器有一个超时,但我不明白为什么.反正有没有避免这个问题?
(用Selenium1和Selenium2测试)
提前致谢
胜利者
<iframe width="100%" scrolling="yes" height="100%" frameborder="0" src="/detail.aspx=" name="displayIFrame"></iframe>
<html>
<head>
<frameset framespacing="1" onload="ScrollToAnchor('text', 'Docln', false); if (document.all) {var h = doccontext.document.all.docContextContentDiv.offsetHeight; document.body.rows = h + ',*,22';}" rows="95,*,22" >
<frame scrolling="no" title="Heading frame" src="head.aspx" name="head"></frame>
<frame scrolling="yes" title="Content frame" src="content.aspx" name="text"></frame>
<frame scrolling="no" title="Footer frame" src="footer.aspx" name="footer"></frame>
</frameset>
Run Code Online (Sandbox Code Playgroud)
我有类似的东西:
Selenium.SelectFrame("displayIFrame");
Selenium.SelectFrame("head");
Selenium.SelectFrame("text"); // I get "ERROR: Not a frame: text"
Run Code Online (Sandbox Code Playgroud)
为什么我得到错误:不是框架:文本从上面的html代码,"text"是我试图选择的框架的名称.好像我正在做的一切正确.请帮帮我.
我是selenium的新手.我想知道如何向用户显示鼠标箭头运动.我的意思是说我们自动化某些事情..我想知道我们如何将鼠标箭头移动到用户身上看到selenium正在进行自动化.可能吗 ???
我们可以清楚地显示被点击的内容,我的意思是鼠标箭头移动点击了哪个按钮.
我希望我很清楚
我在使这个测试用例工作时遇到了问题.谁能指出我正确的方向?我知道我做错了什么,我只是不知道是什么.
import org.junit.*;
import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.*;
@SuppressWarnings("deprecation")
public class register extends SeleneseTestCase {
Selenium selenium;
private SeleniumServer seleniumServer;
public static final String MAX_WAIT = "60000";
public final String CRN = "12761";
public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setAvoidProxy(true);
rc.setSingleWindow(true);
rc.setReuseBrowserSessions(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://google.com/");
seleniumServer.start();
selenium.start();
}
@Test
public void register_test() throws Exception {
//TESTS IN HERE
}
@After
public void tearDown() throws Exception {
selenium.stop();
// …Run Code Online (Sandbox Code Playgroud) 我在一台机器上运行selenium hub,让它成为hub_machine,我正在从机器(m1,m2,m3)向该集线器注册节点.我能够毫无问题地完成这一部分.现在使用远程Web驱动程序,我将命令从m1,m2,m3传递到hub_machine,使用下面的代码调用这些机器上的浏览器.
WebDriver selenium =新的RemoteWebDriver(新的URL(" http:// localhost:4444/wd/hub "),DesiredCapabilities.chrome());
但是当我这样做时,由于三个节点已注册到集线器,集线器正在可用节点列表中的第一个节点上创建新会话.如何指定集线器以在特定节点上创建会话?
如何在硒3中执行webdriver支持的硒?
Selenium 3最近取消了名为'webdriver backed selenium'的功能
我必须执行鼠标悬停,键入这样的操作,这在Selenium 3中不再受支持.
selenium = new WebDriverBackedSelenium(driver, "http://www.google.com");
selenium.openWindow("http://www.google.com", "google");
selenium.mouseOver(anElement);
Run Code Online (Sandbox Code Playgroud)
我已尝试使用moveToElement方法,但它不会在我的网站中执行.这就是我在Selenium 2(WebDriver)中使用webdriver支持的selenium的原因.
在Selenium 3中我需要做些什么来解决这个问题
selenium automation browser-automation selenium-rc selenium3
selenium-rc ×10
selenium ×9
firefox ×2
java ×2
automation ×1
c# ×1
capybara ×1
eclipse ×1
facebook ×1
iframe ×1
junit ×1
macos ×1
selenium-ide ×1
selenium3 ×1
testing ×1