我正在使用Python绑定来运行Selenium WebDriver.
from selenium import webdriver
wd = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)
我知道我可以抓住这样的一个元素......
elem = wd.find_element_by_css_selector('#my-id')
Run Code Online (Sandbox Code Playgroud)
而且我知道我可以获得完整的页面来源...
wd.page_source
Run Code Online (Sandbox Code Playgroud)
但无论如何要获得"元素来源"?
elem.source # <-- returns the HTML as a string
Run Code Online (Sandbox Code Playgroud)
用于Python的selenium webdriver文档基本上不存在,我在代码中看不到任何似乎启用该功能的内容.
有关访问元素(及其子元素)的HTML的最佳方法的任何想法?
python selenium automated-tests webdriver selenium-webdriver
在Selenium 1.x或2.x中是否有任何方法可以滚动浏览器窗口,以便XPath识别的特定元素可以在浏览器中查看?Selenium中有一个焦点方法,但它似乎没有在FireFox中物理滚动视图.有没有人对如何做到这一点有任何建议?
我需要这个的原因是我正在测试页面上元素的点击.不幸的是,除非元素可见,否则事件似乎不起作用.我无法控制单击该元素时触发的代码,因此我无法对其进行调试或修改,因此,最简单的解决方案是将项目滚动到视图中.
我希望它只是我,但Selenium Webdriver看起来像是一场彻头彻尾的噩梦.Chrome webdriver目前无法使用,而其他驱动程序则非常不可靠,或者看起来如此.我正在与许多问题作斗争,但这里有一个问题.
随机地,我的测试将失败
"org.openqa.selenium.StaleElementReferenceException: Element is no longer attached
to the DOM
System info: os.name: 'Windows 7', os.arch: 'amd64',
os.version: '6.1', java.version: '1.6.0_23'"
Run Code Online (Sandbox Code Playgroud)
我正在使用webdriver版本2.0b3.我已经看到FF和IE驱动程序发生这种情况.我可以阻止这种情况的唯一方法是Thread.sleep在异常发生之前添加实际调用.这是一个糟糕的解决方法,所以我希望有人可以指出我的错误,这将使这一切变得更好.
我正在使用带有Cucumber和Capybara的Ruby on Rails.
我将如何测试一个简单的确认命令("你确定吗?")?
另外,我在哪里可以找到有关此问题的进一步文档?
我是量角器的新手,我正在尝试实施e2e测试.我不知道这是否是正确的方法,但是...我要测试的页面不是基于完整的角度页面,所以......我遇到了一些麻烦.
根据我的第一个规范,我有:
describe('should open contact page', function() {
var ptor = protractor.getInstance();
beforeEach(function(){
var Login = require('./util/Login');
new Login(ptor);
});
Run Code Online (Sandbox Code Playgroud)
我已创建此Login类,但登录后我想打开联系页面,但量角器会在页面完全加载之前立即尝试查找元素.
我试过用:
browser.driver.wait(function() {
expect(browser.findElement(by.xpath("//a[@href='#/contacts']")).isDisplayed());
ptor.findElement(by.xpath("//a[@href='#/contacts']")).click();
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用......它总是试图在页面加载之前找到元素.我也试过这个:
browser.driver.wait(function() {
expect(ptor.isElementPresent(by.xpath("//a[@href='#/contacts']")));
ptor.findElement(by.xpath("//a[@href='#/contacts']")).click();
});
Run Code Online (Sandbox Code Playgroud)
我能够使用browser.sleep();但我不认为这是一个不错的选择.任何的想法?在我的登录课上,我有:
ptor.ignoreSynchronization = true;
Run Code Online (Sandbox Code Playgroud)
@href='#/contacts在量角器尝试点击它之前,我该如何等待?
javascript automated-tests angularjs selenium-webdriver protractor
如何为Selenium编写函数以等待Python中只有类标识符的表?我有一个学习使用Selenium的Python webdriver功能的魔鬼.
出于某种原因,我无法在Visual Studio 2012中打开测试资源管理器窗口.我单击测试 - > Windows->测试资源管理器,没有任何反应......
此问题可能是由于最近卸载DotCover引起的.我之所以这样做,是因为我的许可证已过期,而且在没有它的情况下运行测试时出现问题(上下文菜单无效).
任何建议或建议非常感谢!
谢谢.
unit-testing dotcover visual-studio-2012 test-explorer visual-studio-2015
我的任务是抓取使用React构建的网站.我正在尝试填写输入字段并使用javascript注入页面提交表单(在移动设备中使用selenium或webview).这就像每个其他网站+技术的魅力,但React似乎是一个真正的痛苦.
所以这是一个示例代码
var email = document.getElementById( 'email' );
email.value = 'example@mail.com';
Run Code Online (Sandbox Code Playgroud)
我在DOM输入元素上更改了值,但React不会触发change事件.
我一直在尝试各种不同的方法来让React更新状态.
var event = new Event('change', { bubbles: true });
email.dispatchEvent( event );
Run Code Online (Sandbox Code Playgroud)
徒劳无功
var event = new Event('input', { bubbles: true });
email.dispatchEvent( event );
Run Code Online (Sandbox Code Playgroud)
不工作
email.onChange( event );
Run Code Online (Sandbox Code Playgroud)
不工作
我无法相信与React的互动变得如此困难.我非常感谢任何帮助.
谢谢
我必须拖动图像并将其放入CQ5组件中.图像和组件位于不同的帧中.
以下是无效的代码,因为destination当目标框架处于活动状态时无法找到webelement .
new Actions(driver).dragAndDrop(target, destination).perform();
我还尝试在动作之间切换帧:
Actions builder = new Actions(driver);
Actions action = builder.clickAndHold(target);
driver.switchTo().frame("newFrame"); //switching frames
builder.moveToElement(destination);
builder.release(destination);
builder.build();
action.perform();
Run Code Online (Sandbox Code Playgroud)
这也不起作用.然后,我尝试通过偏移移动图像
new Actions(driver).dragAndDropBy(target, x, y).perform(); // x and y
Run Code Online (Sandbox Code Playgroud)
这移动了图像,但组件没有捕获它,可能因为动作太快了.有没有办法可以做这样的拖拽?
提前致谢.
我使用C#语言在NUnit Framework中使用Selenium编写了测试.我想将这些测试作为TFS中构建的一部分.所以每当生成新的构建时.这些测试也可以作为构建和生成/电子邮件报告的一部分运行.
automation ×3
selenium ×3
javascript ×2
python ×2
webdriver ×2
aem ×1
angularjs ×1
capybara ×1
dotcover ×1
integration ×1
java ×1
nunit ×1
protractor ×1
reactjs ×1
scroll ×1
tfsbuild ×1
unit-testing ×1
web-crawler ×1