我检查过这样的其他帖子,但他们无法帮助我。我刚刚开始使用Selenium,而且我在点击单选按钮时遇到了问题。
这是检查员的内容。
input id="createCreds" name="addUser" aria-required="true" ng-model="formData.newUserType" ng-required="addNewUser.$submitted && !formData.newUserType" "="" class="ng-valid ng-valid-required ng-dirty ng-valid-parse ng-touched" aria-checked="true" aria-invalid="false" value="createCreds" type="radio"
以下是我尝试的内容
试用1:
WebElement userRadioBtn = driver.findElement(By.id("createCreds"));
userRadioBtn.click();
试用2:
driver.findElement(By.xpath("//*[@id="createCreds"]']")).click();
试用3:
driver.findElement(By.id("createCreds")).click();
试用4:
input[@value='createCreds']/following-sibling::label
我试图在6分钟左右复制这个家伙。 https://www.youtube.com/watch?v=BKbzW4S2qQ0
我希望能找到类似Click RadioButton css = #createCreds或xpath = // * [@ id =" createCreds"]
答案 0 :(得分:0)
根据您共享的 HTML ,点击单选按钮,因为元素是 Angular 元素,您必须诱导 WebDriverWait ,您可以使用以下任一选项:
cssSelector :
import maya.cmds as cmds
class UserInterface():
def __init__(self):
windowID = "myWindowID"
if cmds.window(windowID, exists = True):
cmds.deleteUI(windowID)
cmds.window(windowID, title="User Interface", sizeable=False, resizetoFitChildren=True)
cmds.rowColumnLayout(numberOfColumns=3,columnWidth=[(1,75), (2,60), (3,60)], columnOffset=[(1,"right",3)]
cmds.showWindow()
xpath :
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.ng-valid.ng-valid-required.ng-dirty.ng-valid-parse.ng-touched#createCreds"))).click();