如何在Selenium webdriver的文本框中输入数值.代码如下: sendKeys()方法不适用于数值,是否有整数的替代命令.
@FindBy(id="toolbox-options-key")
private WebElement BillingRateTextBox;
public void createNewBill(String billingRate)
{
BillingRateTextBox.sendKeys(10);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建测试以验证我的实体是否正在保存在数据库中.当我在post函数中放置断点时,我可以看到保存记录后客户计数发生了变化.我阅读了https://cloud.google.com/appengine/docs/python/tools/localunittesting#Python_Writing_High_Replication_Datastore_tests
根据我的理解,由于最终的一致性,测试失败了,解决这个问题的方法是改变PseudoRandomHRConsistencyPolicy设置.
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
Run Code Online (Sandbox Code Playgroud)
当我再次运行测试时,我得到了同样的错误.
创建这些测试我做错了什么?
> /Users/Bryan/work/GoogleAppEngine/dermalfillersecrets/main.py(137)post()
-> customer.put()
(Pdb) l
134 query = Customer.query()
135 orig_customer_count = query.count()
136 import pdb; pdb.set_trace()
137 -> customer.put()
138 import pdb; pdb.set_trace()
139 query_params = {'leadbook_name': leadbook_name}
140 self.redirect('/?' + urllib.urlencode(query_params))
141
142 config = {}
(Pdb) orig_customer_count
5
(Pdb) c
> /Users/Bryan/work/GoogleAppEngine/dermalfillersecrets/main.py(139)post()
-> query_params = {'leadbook_name': leadbook_name}
(Pdb) l
134 query = Customer.query()
135 orig_customer_count = query.count()
136 import pdb; pdb.set_trace()
137 customer.put()
138 import pdb; pdb.set_trace()
139 …Run Code Online (Sandbox Code Playgroud) python google-app-engine selenium-webdriver google-cloud-datastore nose-gae
我试图使用Selenium Webdriver-Java计算HTML表格中的总行数(不包括标题).
有人可以指导我关于相同步骤的正确方向吗?
提前致谢!
我有一个测试我正在写一个字符串读取然后获取该字符串并将其应用于switch语句.然后我将字符串与case匹配并设置一个整数值,我将其传递回spec页面,然后将int值传递给我用于if语句的另一个测试.我无法让int传递,所以if语句将无法正常工作.
切换对象:
var appsNotPurchased = 0;
this.checksHomeSublevel = function(mmCode) {
browser.get('https://iplan-qa.meetingmatrix.com/Home/Index/' + mmCode);
marketingObjects.level.getText().then(function(text) {
var homeText = text;
browser.get('https://iplan-qa.meetingmatrix.com/Home/Apps/' + mmCode);
expect($('div.apps-subscription > span').getText()).toEqual('iPlan Level: ' + homeText);
switch (homeText) {
case 'Select':
console.log(homeText);
appsNotPurchased = 6;
return appsNotPurchased;
break;
case 'Content':
console.log(homeText);
appsNotPurchased = 0 || 1 || 2 || 3 || 4 || 5 || 6;
return appsNotPurchased;
break;
}
});
Run Code Online (Sandbox Code Playgroud)
testSpec描述函数:
describe('should upload media: ', function() {
it('should select add media', function() {
var mmCode = …Run Code Online (Sandbox Code Playgroud) javascript switch-statement angularjs selenium-webdriver protractor
我们的应用程序包含Web元素表.我的目的是检查内容表是否按字母顺序排列.
WebDriver d=new FirefoxDriver();
d.get("http://www.javatpoint.com/wrapper-class-in-java");
WebElement table=d.findElement(By.xpath(".//*[@id='city']/table/tbody"));
List<WebElement> lst=table.findElements(By.tagName("tr"));
System.out.println(lst);
List ls=new ArrayList<String>();
for(int i=0;i<=6;i++)
{
ls=lst.addAll(get(i).getText())
}
Run Code Online (Sandbox Code Playgroud)
我的目标是将字符串类型webelement存储在一个列表中,并创建另一个列表,该列表在最后比较两个列表中是排序类型.请帮忙.
如何在地址栏中标识具有特定网址的现有打开的Chrome窗口,并使用C#中的Selenium网络驱动程序在该窗口中打开新标签?我看到的所有示例都显示了如何在Selenium ChromeDriver中打开的窗口中打开新选项卡.
IWebDriver driver = null;
var chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
driver = new ChromeDriver(chromeDriverService);
List<string> tabs = new List<string>(driver.WindowHandles);
Run Code Online (Sandbox Code Playgroud)
driver.WindowHandles总是返回ChromeDriver打开的窗口.但是,我正在寻找所有的窗户.一旦执行实例化ChromeDriver的行,就会打开一个新窗口.但是,我需要在现有窗口的新选项卡中打开一个新URL.
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class NewGmail {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
String url = "https://accounts.google.com/signin";
driver.get(url);
driver.findElement(By.id("identifierId")).sendKeys("cp8805");
//driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
WebDriverWait wait=new WebDriverWait(driver, 20);
driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).sendKeys("xxxxxx");
driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();
}
}
Run Code Online (Sandbox Code Playgroud)
在邮件ID之后我的密码也写在id框选项中,服务器重定向到下一个密码页面.我想问一下我将做什么,以便我的密码只能输入密码页面.
如何更改此方法以使用不同数量的元素?有时可能有3个元素,另一个时间5.我希望这个循环可以找到元素,只要它能找到它,如果没有,就可以打破.现在,当只有3个元素时,会出现"无法定位元素"的错误,测试失败.
public void checkProductsInOrder() {
for (int i = 1; i <= 5; i++) {
WebElement element = driver.findElement(By.xpath("(//td[@data-id=\"product_name\"])[" + i + "]"));
wait.until(ExpectedConditions.visibilityOf(element));
productsInOrder.add(element.getText());
}
Run Code Online (Sandbox Code Playgroud) 这是有效的,但我想使用文本Group 1作为变量.
代码试用:
[FindsBy(How = How.XPath, Using = "(.//*[normalize-space(text()) and normalize-space(.)= 'Group 1'])[1]/ancestor::app-organization//*[normalize-space(text()) and normalize-space(.)='Create a new board...']/following::input[1]")]
public IWebElement BoardNameInputField { get; set; }
Run Code Online (Sandbox Code Playgroud)
我试过这个但没有成功:
string boardName = "Group 1";
[FindsBy(How = How.XPath, Using = "(.//*[normalize-space(text()) and normalize-space(.)='${boardName}'])[1]/ancestor::app-organization//*[normalize-space(text()) and normalize-space(.)='Create a new board...']")]
public IWebElement CreateNewBoard { get; set; }
Run Code Online (Sandbox Code Playgroud)
是否有可能做到这一点?
我试过了,
browser.find_element_by_class_name('("my_class")[1]')
browser.find_element_by_class_name('("my_class")[position()=1]')
browser.find_element_by_class_name("my_class")[1]
Run Code Online (Sandbox Code Playgroud) selenium ×7
java ×4
c# ×2
python ×2
angularjs ×1
firefox ×1
geckodriver ×1
javascript ×1
nose-gae ×1
protractor ×1
xpath ×1
xpath-1.0 ×1