我正在尝试使用ansible在多个主机上启动filebeat(或者就任何其他将按需连续运行的进程)进程.我不希望ansible等到进程继续运行.我希望ansible能够解雇并忘记并出来让远程进程在后台运行.我尝试过使用以下选项:
---
- hosts: filebeat
tasks:
- name: start filebeat
option a) command: filebeat -c filebeat.yml &
option b) command: nohup filebeat -c filebeat.yml &
option c) shell: filebeat -c filebeat.yml &
async: 0 //Tried without as well. If its > 0 then it only waits for that much of time and terminates the filebeat process on remote host and comes out.
poll: 0
Run Code Online (Sandbox Code Playgroud) 大家好我想尝试使用getCssValue方法获取extjs 4.2表单控件文本字段的边框颜色.但我无法取得它.它让我空白.下面是我的代码片段,您可以按原样尝试.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestClass
{
public static void main(String[] args) throws InterruptedException
{
WebDriver driver=new FirefoxDriver();
Thread.sleep(2000);
driver.get("http://docs.sencha.com/extjs/4.2.1/extjs-build/examples/form/dynamic.html");
Thread.sleep(2000);
WebElement element=driver.findElement(By.xpath(".//input[@name='first']"));
Thread.sleep(2000);
element.sendKeys("");
element.sendKeys(Keys.TAB);
Thread.sleep(2000);
System.out.println("'"+element.getCssValue("border-color")+"'");
}
}
Run Code Online (Sandbox Code Playgroud)
Webdriver版本2.33(Java绑定)
FF 22
嗨,我正在使用反射来实现某些目标.我已经获得了类名,该类的方法名称和需要在文件中传递给该方法的参数值(获取任何文件.不是约束).我必须用参数调用该方法.此方法不返回任何内容.这个类中有很多方法,每个方法的参数列表各不相同.
例如:method1(String, String, int, boolean)
method1(String, int, boolean)同样我有不同的排列和组合.那么我怎样才能做到这一点.我尝试过使用不同的switch子句进行硬编码,但这是一个真正的开销和冒险的事情.我们可以动态地做这件事,就像在运行中从文件中读取方法名称及其参数并调用它.任何小的代码段都会有所帮助.TIA.
每当我们指定priority,并dependsOnMethods在@Test注释的方法,测试方法执行的顺序不是根据优先级.为什么会这样?以下是演示该问题的测试类:
package unitTest.TestNGTestCases;
import org.testng.annotations.Test;
public class TestNGTest1 {
@Test(priority=1)
public void t1()
{
System.out.println("Running 1");
}
@Test(priority=2,dependsOnMethods="t1")
public void t2()
{
System.out.println("Running 2");
}
@Test(priority=3,dependsOnMethods="t2")
public void t3()
{
System.out.println("Running 3");
}
@Test(priority=4)
public void t4()
{
System.out.println("Running 4");
}
}
Run Code Online (Sandbox Code Playgroud)
实际产量:
Running 1
Running 4
Running 2
Running 3
===============================================
All Tests Suite
Total tests run: 4, Failures: 0, Skips: 0
===============================================
Run Code Online (Sandbox Code Playgroud)
预期产量:
Running 1
Running 2
Running 3
Running 4
=============================================== …Run Code Online (Sandbox Code Playgroud) 我正在尝试moveToElement(element,xoffset,yoffset)在FireFox 21中的硒Web驱动程序(java)中使用Actions类,但似乎无法正常工作。我有一个extjs按钮控件,它既可以用作按钮也可以用作下拉菜单(请参阅屏幕截图)。

当我单击“保存更改”部分时,它会保存更改;当我单击附加的下拉按钮时,它会打开列表。请参考DOM源以获取相同的控件。
<td class="x-btn-mc"><em id="ext-gen514" class="x-btn-split" unselectable="on"><button id="btn-ext-comp-1739" class=" x-btn-text save-changes" type="button"><u>
S
</u>
ave Changes
</button></em></td>
Run Code Online (Sandbox Code Playgroud)
现在,我可以单击“保存更改”按钮,但无法通过在moveToElement方法中提供一些偏移位置来单击下拉按钮。
我尝试了以下两种选择:
builder.moveToElement(element).moveByOffset(569,
5).click().build().perform();builder.moveToElement(element, 568, 5).click().build().perform();但两者都不起作用。
控件的尺寸为(117 x 16)
注意:不要被偏移量568,5弄糊涂,因为该偏移量仍然可以单击保存更改按钮。
最新的Web驱动程序尚不支持此方法吗?
我在 cypress 中遇到以下问题:
到目前为止我拥有的代码:
cy.get("tr[some attribute]").each(($element, $index, $list) => {
cy.wrap($element).find("button").click();
cy.get(".modal-dialog").should('be.visible');
cy.get(".modal-dialog button[type='submit']").should('be.visible').click();
cy.get("toast").should('be.visible').as('@toast')
cy.get('@toast').should('not.be.visible')
})
Run Code Online (Sandbox Code Playgroud)
这里的问题:
提前致谢!
嗨,我是黄瓜java新手.我正在尝试运行简单的黄瓜功能测试.下面是我的功能文件,步骤定义文件和junit runner文件.但我无法在cucumber-java,cucumber-junit 1.1.6版本中成功运行测试.
功能文件
Feature: Test if f1 feature is working
Scenario: valid scenario
Given input1 is "t"
When input2 is also "t"
Then result should be "pass"
Run Code Online (Sandbox Code Playgroud)
Stepdefinition文件
package cucumberFrameworkPractise;
import org.junit.Assert;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class CucumberStepDefinitionTest {
String input1,input2,result;
@Given("input1 is \"([^\"]*)\"$")
public void input1(String input1)
{
this.input1=input1;
}
@When("input2 is also \"([^\"]*)\"$")
public void input2(String input2)
{
this.input2=input2;
}
@Then("result should be \"([^\"]*)\"$")
public void result(String result)
{
this.result=result;
Assert.fail();
}
}
Run Code Online (Sandbox Code Playgroud)
黄瓜亚军文件 …
如何在黄瓜java绑定中定义步骤定义时使用varargs的强大功能.我有下面的步骤
Given I have following product: prod1, prod2, prod3
Run Code Online (Sandbox Code Playgroud)
我的步骤定义
@Given("^I have following product [(exhaustive list of products or pattern of the product names)]$")
public void stepDef(String...args)
{
//Process varargs array "args" in here
}
Run Code Online (Sandbox Code Playgroud)
我知道解决方法可以是除了冒号后的完整字符串,然后在代码中使用split(",")拆分字符串并将其转储到数组中.但我只是想知道黄瓜本身是否支持varargs模式.
TIA!
我试图在Firefox浏览器代码中使用selenium webdriver 2.47.0版本中添加的WebElement#getScreenShotAs(OutputType.FILE)功能
public static void main(String[] args) throws IOException {
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://automationpractice.com/index.php");
WebElement element=driver.findElement(By.cssSelector("a[title='Contact Us']"));
System.out.println(element.getText());
element.getScreenshotAs(OutputType.FILE);
File destination=new File("Image.png");
FileUtils.copyFile(null, destination);
}
Run Code Online (Sandbox Code Playgroud)
..但我得到以下异常:
Contact us
Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: Unrecognized command: GET /session/e796089b-1d64-4590-9157-a0716a57e399/screenshot/%7B4329461b-5e9c-4f8b-b589-ddc1af1d55a6%7D
Command duration or timeout: 16 milliseconds
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'mrunal-laptop', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=41.0.2, …Run Code Online (Sandbox Code Playgroud) 我有这个要求迭代结果集中返回的数百万条记录并处理它们并将它们存储在某些数据结构中。我找不到任何相关的例子或参考。JOOQ 似乎在做一些我可能想要的事情,但它似乎不是免费的。我希望如果使用 java 8 流我可能能够实现它,但不是 example 或 writeup 似乎给了我任何前进的方向。我也对其他选择持开放态度。
基于这个 SO 参考:resultset parallel我在下面尝试过,但它没有给我任何性能改进,如下面的性能指标所示。
代码:顺序迭代:
while(rs.next()) {
System.out.println(rs.getString(1));
}
Run Code Online (Sandbox Code Playgroud)
使用流和拆分器:
Stream<String> s = StreamSupport.stream(new Spliterators.AbstractSpliterator<String>(Long.MAX_VALUE,
Spliterator.ORDERED) {
@Override
public boolean tryAdvance(Consumer<? super String> action) {
try {
if (!rs.next())
return false;
action.accept(rs.getString(1));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
}, true);
s.forEach(System.out::println);
Run Code Online (Sandbox Code Playgroud)
记录总数:3759
Sequential 花费的时间:~83.8 secs
Streams 花费的时间:~83.5 secs
任何人都可以查看并告诉我我是否没有正确实现流。
我试图检查服务是否正在运行,然后将其输出注册到某个变量,如果它没有运行,则启动服务。下面是我的 Ansible 剧本片段。
- hosts: localhost
tasks:
- name: check if service is running
shell: pgrep node
register: pgrep
- name: stop running service
shell: pkill node
when: pgrep.stdout_lines != ''
tags:
- stop
- name: start running service
shell: pkill node
when: pgrep.stdout_lines == ''
tags:
- start
Run Code Online (Sandbox Code Playgroud)
现在在上述情况下,如果进程未运行,则该pgrep node命令将退出状态代码返回为 1,这将使“检查服务是否正在运行”任务失败并中止进一步执行任务。我知道通过设置ignore_errors: true将忽略错误并继续进行,但它无法运行 Ansible。有没有办法可以优雅地处理这个问题?
我正在尝试使用Appium来测试计算器应用程序(仅出于知识目的)。但是我无法执行任何操作。以下是详细信息:
Real Mobile:小米Redmi注意事项3
Android版本:6.0.1
MIUI:8.1
Appium版本:1.4.16
Android SDK版本:24.4.1
appium Java客户端:4.1.2
代码:
package unittest;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class LaunchWardRobe {
@Test
public void swipeTest() throws IOException {
String propFileName = "wardrobe.properties";
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(propFileName);
Properties prop = new Properties();
prop.load(inputStream);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, prop.getProperty("cap.platform.version"));
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, prop.getProperty("cap.platform.name"));
cap.setCapability(MobileCapabilityType.DEVICE_NAME, prop.getProperty("cap.device.name"));
cap.setCapability("appPackage", prop.getProperty("cap.app.package"));
cap.setCapability("appActivity", prop.getProperty("cap.app.activity"));
cap.setCapability(MobileCapabilityType.BROWSER_NAME, "");
cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");
AndroidDriver<MobileElement> browser = …Run Code Online (Sandbox Code Playgroud) java ×9
selenium ×3
ansible ×2
extjs ×2
appium ×1
automation ×1
bdd ×1
css ×1
cucumber ×1
cucumber-jvm ×1
cypress ×1
dynamic ×1
java-8 ×1
java-stream ×1
jdbc ×1
reflection ×1
resultset ×1
testing ×1
testng ×1
webdriver ×1