我试图使用的Arquillian无人机驾驶员我的测试,但是,出于某种原因注释@Before
,@After
,@BeforeClass
并且@AfterClass
被完全忽略.
我是Java/jUnit/Arquillian环境的新手(一直使用Python),所以我可能会在这里犯一些愚蠢的错误.
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import com.eyereturn.warlock.client.pages.login.LoginPage;
@RunWith(Arquillian.class)
public class TestDroneLogin {
@Drone
private WebDriver driver;
@Before
public void setup(){
driver.navigate().to("http://google.com");
}
@Test
public void testInput(){
driver.findElement(By.cssSelector("input#gbqfq"));
}
}
Run Code Online (Sandbox Code Playgroud)
arquillian.xml:
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<extension qualifier="webdriver">
<property name="browserCapabilities">chrome</property>
</extension>
</arquillian>
Run Code Online (Sandbox Code Playgroud)
pom.xml中:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproj</groupId>
<artifactId>proj-integration-tests</artifactId>
<version>1.0.0-SNAPSHOT</version> …
Run Code Online (Sandbox Code Playgroud) 在将Firefox升级到版本19之后,我的Selenium Webdriver测试最近破了.在我的几个测试中,我需要检索页面上但在浏览器窗口中看不到的元素,即我必须向右滚动才能看到它们.自升级到Firefox 19(我从15升级,因此这可能是16以来的问题)我只能检索我可以在浏览器窗口看到的元素的文本.我的xpath正确检索所有元素,例如在我的下面的代码中:
private void buildColumnsMap(){
allColumnHeaders = new HashMap<String,Integer>();
positionToColumnName = new ArrayList<String>();
WebElement columnsRoot = driver.findElement(By.xpath(COLUMNS_ROOT_XPATH));
List <WebElement> columns = columnsRoot.findElements(By.xpath("./td/div/span"));
System.out.println("Number of columns found: " + columns.size());
for(int i = 0; i < columns.size(); ++i){
String columnName = columns.get(i).getText();
System.out.println("Column been inserted: " + columnName);
allColumnHeaders.put(columnName, i);
positionToColumnName.add(columnName);
}
}
Run Code Online (Sandbox Code Playgroud)
列"列"的大小为38,但在我的浏览器窗口中,我只能看到10列而不必滚动所以当我将列名放入我的对象时,我得到10个列名,然后是所有空白.
Number of columns found: 38
Column been inserted: Date/Time
Column been inserted: Endpoint1
Column been inserted: Endpoint2
Column been inserted: Duration
Column been inserted: Codec1
Column …
Run Code Online (Sandbox Code Playgroud) 我正在使用selenium 2和chrome驱动程序,无论我做什么,似乎无法明确等待工作.我试图点击一个元素,它通过ajax动态生成一些数据(没有重新加载),然后当它出现在页面上时搜索一个元素.
这是我的代码
leagueNameItem.Click();
IList<IWebElement> outerTables_forEachLeague = new List<IWebElement>();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
outerTables_forEachLeague = wait.Until<IList<IWebElement>>((d) =>
{
return d.FindElements(By.ClassName("boxVerde"));
});
Run Code Online (Sandbox Code Playgroud)
找不到该元素(它肯定在页面上).等待函数实际上并没有"等待"10秒,因为指定的ut只返回任何内容.有什么想法吗?
来自服务器的HTML中有类似的东西:
<html ...>
<head ...>
....
<link href="http://mydomain.com/Digital_Cameras--~all" rel="canonical" />
<link href="http://mydomain.com/Digital_Cameras--~all/sec_~product_list/sb_~1/pp_~2" rel="next" />
...
</head>
<body>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果b保持浏览器对象导航到我需要查看的页面,我能够找到rel="canonical"
with b.html.include?
语句,但是如何检索找到此子字符串的整行?我还需要下一个(非空).
我在Windows 7上使用Firefox 21和C#WebDriver 2.33.我很困惑为什么以下测试失败(我只是检查我的配置设置是否正确).这在其他浏览器中传递.
[Test]
public void FirefoxDriverWorks()
{
var firefoxDriver = new FirefoxDriver();
TestGoogleStillExists(firefoxDriver);
firefoxDriver.Quit();
}
public void TestGoogleStillExists(IWebDriver webDriver)
{
webDriver.Navigate().GoToUrl("http://www.google.com");
var title = webDriver.FindElement(By.CssSelector("head title"));
Assert.That(title.Text, Is.EqualTo("Google"));
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码双击我的Web应用程序中的表格中的单元格(我试图单击两次,希望它们等于双击).但是,根本没有单击该单元格,但我希望在双击单元格后,将显示文本字段以便我编辑该单元格的信息.
@driver.find_element(:xpath => "//table[@id='gridabc']//tr[1]/td[9]").click
@driver.find_element(:xpath => "//table[@id='gridabc']//tr[1]/td[9]").click
Run Code Online (Sandbox Code Playgroud)
我正在使用Selenium Ruby Webdriver.请帮助指导我解决此问题的方法.非常感谢.
请帮助给我一个解决方案来比较Web应用程序的两个URL中的两个图像是否相同(我的意思是每个图像中的内容是相同的)或不使用Selenium Ruby Webdriver.
例如:我在访问以下网址时显示的图片很小:
http://testing.com/image1.png
Run Code Online (Sandbox Code Playgroud)
访问以下网址时,我还有另一张图片:
http://testing.com/image2.png
Run Code Online (Sandbox Code Playgroud)
如何使用Selenium Ruby Webdriver比较这两个图像以查看它们是否相同?任何建议表示赞赏.非常感谢.
我正在尝试填写两个表格并登录我的银行网站.
我可以获得填写用户名的第一个表单,但我似乎无法获取填写密码的表单.
这是我正在使用的代码:
from splinter import Browser
username2 = '***'
password2 = '***'
browser2 = Browser()
browser2.visit('http://mijn.ing.nl')
browser2.find_by_css('.firstfield').fill(username2)
browser2.find_by_id('#easnhbcc').fill(password2)
Run Code Online (Sandbox Code Playgroud)
这是完整的追溯:
/usr/local/bin/python2 "/Users/narekaramjan/Dropbox/Python/Python 273/Test.py"
Traceback (most recent call last):
File "/Users/narekaramjan/Dropbox/Python/Python 273/Test.py", line 26, in <module>
browser2.find_by_id('#easnhbcc').fill(password2)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splinter/element_list.py", line 73, in __getattr__
self.__class__.__name__, name))
AttributeError: 'ElementList' object has no attribute 'fill'
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
browser2.find_by_name('easnhbcc').fill(password2)
Run Code Online (Sandbox Code Playgroud)
如何获取密码表格?
环境:使用Java的Selenium Webdriver
1)运行搜索
2)搜索后5个项目将显示5个复选框对他们
3)我想得到复选框的数量
4)复选框有类名"复选框"
请建议
谢谢 !!
我正在尝试编写一个自动登录到两个网站并转到某个页面的代码.我用Splinter.
我只使用PhantomJS作为浏览器类型在"Mijn ING Zakelijk"网站上收到错误.
直到几天前,代码在20次中完美地运行了20次.但是从今天起我就收到了错误.有时代码运行正常.其他时候它没有,并给我"点击成功,但加载失败.."错误.这是完整的追溯:
## Attempting to login to Mijn ING Zakelijk, please wait.
- Starting the browser..
- Visiting the url..
- Filling the username form with the defined username..
- Filling the password form with the defined password..
- Clicking the submit button..
Traceback (most recent call last):
File "/Users/###/Dropbox/Python/Test environment 2.7.3/Splinter.py", line 98, in <module>
mijning()
File "/Users/###/Dropbox/Python/Test environment 2.7.3/Splinter.py", line 27, in mijning
attemptLogin(url2, username2, password2, defined_title2, website_name2, browser_type2)
File "/Users/###/Dropbox/Python/Test …
Run Code Online (Sandbox Code Playgroud)