Selenium webdriver需要选中一个复选框

时间:2016-09-14 03:57:52

标签: selenium xpath selenium-webdriver

我需要选中一个名为标准的复选框

请看截图。

enter image description here

我可以通过以下方式展开information type下拉菜单:

By.xpath("//div[contains(@class, 'expand') and h3[contains(text(), 'Information Type')]]") 

1 个答案:

答案 0 :(得分:1)

展开using ppdai.user.vip.model; using System; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; using System.Data.Entity.ModelConfiguration.Configuration; namespace ppdai.user.vip.model.mapping { public class GoodsMapping: EntityTypeConfiguration<Goods> { public GoodsMapping() { this.Property(x => x.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); this.HasKey(x => x.Id); this.Property(x => x.GoodsQuantity).IsRequired(); this.Property(x => x.GoodPrice).IsRequired(); this.Property(x => x.GoodScore).IsRequired(); this.Property(x => x.GoodTypeId).IsRequired(); this.HasRequired(x => x.GoodType) .WithMany(x => x.Goods) .HasForeignKey(x => x.GoodTypeId); } } } 元素后,您应该等到Information Type复选框元素变为可见并可使用Standards点击,如下所示: -

WebDriverWait

您也可以使用此new WebDriverWait(driver,10).until(ExpectedConditions.elementToBeClickable(By.xpath(".//li[normalize-space(.)='Standards']/input"))).click();

xpath