Selenium Webdriver - using isDisplayed() in If statement is not working -
I am creating a script that was to search for records and then to update the records. On the search screen, a user has the option of viewing advanced search options. Toggle to show or hide advanced search is controlled by a button.
& lt; A title = "search" href = "javascript: extended filter ()" & gt; IMG boundary = "0" align = "gram" alt = "advanced" src = "**** MASKED URL ****" & gt; & Lt; / A & gt; The difference between the properties of the search button when it is showing or hiding advanced search img src:
When Advanced Search is hidden IMG src "/ Styles /_Images/advanced_button.jpg "when advanced search appears, IMG src ends with" /Styles/_Images/basic_button.png "
when I open the page Sometimes, advanced search options are visible, sometimes it is not. The value that I want to find appears in the Advanced section, so I have added the IF statement to work for my script.
& lt; Input type = "text" value = "" maxlength = "30" size = "30" name = "GUI system ID" & gt; The IF statement appears for the field, in which I need to enter the data, and if the field is not present, it will indicate that advanced options are not visible. I need the button to expand the search option.
I created the following IF statement.
if (! Driver.findElement (by.name ("guiSystemID") isDisplayed ()) {Driver.findElement (by.cssSelector ("img [alt = 'advanced']") ();} When I run the script and the advanced search is expanded then the script runs successfully. However, when I run the script and not expand the Advanced Search If the script fails, I recommend that the object "GUISystemID" could not be found. It is disappointing because if it can not be found So, I want to continue the script, I'm entering the correct path of IF statement.
Has anyone got any suggestions about how I can evaluate this area The script is showing up without fail because this field can not be found.
Thanks in advance
Simon
I may be late in answering it, but that Mr. and could seek help.
I have recently encountered a similar problem). My code was something like
if (driver.findElement (By.xpath (noRecordId) isDisplayed ()) {/ ** it * /} and {/ ** do it} This code works very well when the element displayed is present. But when the element is absent, then it is looking for it and therefore throws an exception "NosuchElementFound". So there was no way I could check the other part.
I picked up a way to work on it (with trying and blocking block, say something like this). P>
Public Zero Deletion SBVR () throws an exception { Try (if driver.findElement (By.xpath (noRecordId) isDisplayed ()) {/ ** when the element is found * /}} hold (exception E) {/ ** include the second part in it} } Hope this helps :)
Comments
Post a Comment