Vid*_*ids 28 selenium-webdriver
按TAB键,然后按Selenium WebDriver中的ENTER键
GenericKeywords.typein(class.variable,PageLength); pagelength只不过是字符串.
在这段代码之后,我必须给Tab键.我不知道如何在Selenium WebDriver中提供Tab键?
小智 45
使用Java:
WebElement webElement = driver.findElement(By.xpath(""));//You can use xpath, ID or name whatever you like
webElement.sendKeys(Keys.TAB);
webElement.sendKeys(Keys.ENTER);
Run Code Online (Sandbox Code Playgroud)
在 javascript (node.js) 这对我有用:
describe('UI', function() {
describe('gets results from Bing', function() {
this.timeout(10000);
it('makes a search', function(done) {
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://bing.com');
var input = driver.findElement(webdriver.By.name('q'));
input.sendKeys('something');
input.sendKeys(webdriver.Key.ENTER);
driver.wait(function() {
driver.findElement(webdriver.By.className('sb_count')).
getText().
then(function(result) {
console.log('result: ', result);
done();
});
}, 8000);
});
});
});
Run Code Online (Sandbox Code Playgroud)
对于选项卡使用 webdriver.Key.TAB
| 归档时间: |
|
| 查看次数: |
136304 次 |
| 最近记录: |