Home > Enterprise >  How to identify an element in Selenium
How to identify an element in Selenium

Time:09-17

I am trying to click on a button which appears as a web popup

On Inspect Element I have the following code .

<input type="button" id="#ICYes" name="#ICYes" class="PSPUSHBUTTONTBYES" value="Yes" 
onclick="javascript:oParentWin.submitAction_win0(oParentWin.document.win0, '#ICYes');
closeMsg(null,modId);" tabindex="0" alt="Yes" title="Yes">
driver.findElement(By.id("#ICYes")).click();

is not working

CodePudding user response:

You have to remove the hashtag from the id since the driver is already searching specifically for an id that is "ICYes".

driver.findElement(By.id("ICYes")).click();

CodePudding user response:

[python]

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '#ICYes'))).click() or

driver.find_element_by_css_selector('#ICYes').click()

api - https://selenium-python.readthedocs.io/locating-elements.html

  • Related