我正在尝试点击一个元素并尝试使用sendkeys。
我能够看到元素的ID和名称,但是当我试图点击它时,它正在给我:
无法找到元素:#customer_firstname
检查以下HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<div class="row">
<div class="col-md-12" id="page1">
<div class="list-group">
<a href="bericht.html" class="list-group-item list-group-item-action flex-column align-items-start">
<div class="col-md-2">
<img src="https://www.jennybeaumont.com/wp-content/uploads/2015/03/placeholder-800x423.gif" alt="" style="width: 100%">
</div>
<div class="col-md-6">
<h6 class="mb-1">Bootstrap element out of alignment</h6>
<p class="mb-1" style="font-size: 14px">Donec id elit non mi porta gravida at eget metus. Maecenas...</p>
<small class="float-right text-muted">25 minuten geleden door Henk</small>
</div>
<div class="col-md-2">
<h6 class="text-center">Reacties</h6>
<p class="text-center">57</p>
</div>
<div class="col-md-2">
<h6 class="text-center">Weergaven</h6>
<p class="text-center">2.543</p>
</div>
</a>
</div>
</div>
</div>
我只是尝试过id,name和xpath。
<input onkeyup="$('#firstname').val(this.value);" class="is_required validate form-control" data-validate="isName" id="customer_firstname" name="customer_firstname" value="" type="text">
这是代码
driver.findElement(By.id("customer_firstname")).sendKeys("ddddd");
driver.findElement(By.name("customer_firstname")).sendKeys("ddddd");
driver.findElement(By.xpath(".//*[@id='customer_firstname']")).sendKeys("ddddd");