在使用python的Windows上使用Selenium Webdriver截取屏幕截图时,屏幕截图直接保存到程序的路径中,有没有办法将.png文件保存到特定目录?
如何Selenium WebDriver在java中自动执行拖放功能?
什么相当于selenium.focus()WebDriver?
element.sendKeys("");
Run Code Online (Sandbox Code Playgroud)
要么
new Actions(driver).moveToElement(element).perform();
Run Code Online (Sandbox Code Playgroud)
我已经尝试了他们两个并且他们工作了,但哪一个总是适用于所有元素?
对于任何元素(例如按钮,链接等),哪一个是正确的方法?这对我很重要,因为该功能将用于不同的UI.
我正在尝试将请求标头"Referer"设置为欺骗来自其他网站的请求.我们需要使用特定引用者的能力测试,它将特定的表单返回给用户,否则给出另一种形式.
我可以通过以下方式在恶作剧中做到这一点:
page.driver.headers = {"Referer" => referer_string}
Run Code Online (Sandbox Code Playgroud)
但我找不到selemium驱动程序的等效功能.
如何在capybara selenium驱动程序中设置请求标头?
如何设置Selenium以使用Python?我只想用Python编写/导出脚本,然后运行它们.有没有资源可以教我如何做到这一点?我试过谷歌搜索,但我发现的东西要么是指过时版本的Selenium(RC),要么是过时版本的Python.
我想sometext12345_text使用下面的正则表达式匹配以下文本.我在我的一个硒测试中使用它.
String expr = "//*[contains(@id, 'sometext[0-9]+_text')]";
driver.findElement(By.xpath(expr));
Run Code Online (Sandbox Code Playgroud)
它似乎不起作用.有人可以帮忙吗?
我是量角器的新手,我正在尝试实施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
是否有任何方法可以让python + selenium找到父元素,兄弟元素或子元素
driver.find_element_parent?或
driver.find_element_next?或
driver.find_element_previous?
例如:
<tr>
<td>
<select>
<option value=0, selected='selected'> </option>
<option value=1, > </option>
<option value=2,> </option>
</select>
</td>
<td> 'abcd'
<input name='A'> </input>
<td>
<tr>
Run Code Online (Sandbox Code Playgroud)
我尝试过如下,但失败了:
input_el=driver.find_element_by_name('A')
td_p_input=find_element_by_xpath('ancestor::input')
Run Code Online (Sandbox Code Playgroud)
如何获取input元素的父元素,最后选择选项?
我在用:
driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS);
Run Code Online (Sandbox Code Playgroud)
但是对于下面的元素,它仍然会不断失败
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("Create_title_01");
Run Code Online (Sandbox Code Playgroud)
我添加了等待代码:
for (int second = 0;; second++) {
if (second >= 120) fail("timeout");
try { if (isElementPresent(By.id("name"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
Run Code Online (Sandbox Code Playgroud)
不应该隐含等待,直到找到一个元素?如果我使用显式等待而不是我添加的代码,它会更好Thread.sleep()吗?
我刚刚更新到Firefox 32,当我尝试运行我的Selenium Webdriver测试时,我得到以下内容
Failed to start up socket within 45000 ms. Attempted to connect to the
following addresses: 127.0.0.1:7055 OpenQA.Selenium.WebDriverException
was unhandled by user code HResult=-2146233088 Message=Failed to
start up socket within 45000 ms. Attempted to connect to the following
addresses: 127.0.0.1:7055 Source=WebDriver StackTrace:
at OpenQA.Selenium.Firefox.FirefoxDriverServer.ConnectToBrowser(TimeSpan
timeToWait)
at OpenQA.Selenium.Firefox.FirefoxDriverServer.Start()
at OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(Command
commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities
desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor
commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile, ICapabilities capabilities, TimeSpan
commandTimeout)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile, TimeSpan …Run Code Online (Sandbox Code Playgroud) selenium ×6
java ×3
python ×3
webdriver ×2
xpath ×2
angularjs ×1
capybara ×1
contains ×1
firefox ×1
focus ×1
javascript ×1
parent-child ×1
protractor ×1
regex ×1
setfocus ×1