具有相同DIV类的java自动组合框
我正在尝试自动化Naukari。com创建工作提醒页面,我们有行业字段和工作角色字段。两者都是带有复选框的组合框。对于工业领域,我使用了下面的脚本
//Clicking on the industry dropdown
//driver.findElement(By.xpath("//input[contains(@placeholder,'Type or Select')]")).click();
//Selecting the checkbox containing text as "Accounting"
//driver.findElement(By.xpath("//ul[@class='ChkboxEnb']//a[contains(text(),'Accounting')]")).click();
//Selecting the checkbox containing text as 'Government'
//driver.findElement(By.xpath("//ul[@class='ChkboxEnb']//a[contains(text(),'Government')]")).click();
但对于工作角色领域,我再次面临这个问题,因为div的课程是一样的。我还试着使用//input[contains(@id,'given_id')]")).click();
但它不起作用。请帮忙
# 1 楼答案
请尝试以下代码(适用于FF和Chrome):