i already used all possible scripts and i cannot click this button
element location
Submit
Did u try webelement in selenium Xpath=//tagname[#attribute='value'] ?
Related
when I open a particular webpage it has a EULA form that appears on top of the home page in the form of a modal in HTML/CSS. I have tried the XPath of the accept button but it says element not found also tried using handle alert.
is there a unique way to handle a dialogue box in robotframework?
image of HTML in inspect view
SeleniumLibrary.Set Focus To Element ${button_on_popup_page}
SeleniumLibrary.Click Element ${button_on_popup_page}
I figured it out, shown in the above code. I first set focus to the button and then used the click element. This seemed to work.
There is a "Save" button in my application which is enabled upon selection of a value in a dropdown i.e. "Language".
When using Selenium for this, even after selecting this value, the button is not enabled, and hence the test fails, since Selenium is not able to click on the disabled button.
When this dropdown is manually selected the button is enabled.
For selecting the value from drop down i am using "Select" class.
How can i handle this scenario
you can try using javascript executor which will execute to turn button enabled from disabled condition,
WebElement btn= driver.findElement(By.SELECTOR("LOCATOR"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].removeAttribute('disabled')",btn);
Is there any way on how to click a hidden button by an overlapped input text field, for example if you go to www.google.com and enter a text to search for, selenium can not find the "Search Google" button because it is hidden by the autocomplete of the text field.
Thanks.
You can bypass the validation by using #click! instead of #click. Basically, this triggers the click via JavaScript rather than through standard Selenium commands.
browser = Watir::Browser.new
browser.goto('www.google.com')
browser.text_field(name: 'q').set('watir')
browser.button(name: 'btnK').click!
If you are only using Selenium, you can do:
btn = driver.find_element(name: 'btnK')
driver.execute_script('arguments[0].click();', btn)
As discussed in the comments, you could also close the suggestions box before trying to click the button. You can do this by moving focus to any other element - eg the first link on the page. Depending on what you're testing, this may or may not have value.
browser.text_field(name: 'q').set('watir')
browser.link.focus # move focus to any other element so suggestions close
browser.button(name: 'btnK').click
I am using selenium with IE to automate web testing. My webpage fills out a form and finally clicks a button. Code to click button is
driver.FindElement(By.CssSelector("td.ne-fieldvalues > input[type=\"button\"]")).Click();
8 out of 10 times, it Clicks but other time click command is never executed.
Is there way I can check if button was indeed clicked ? something similar to checkbox
if (!driver.FindElement(By.CssSelector("input[type=\"checkbox\"]")).Selected)
driver.FindElement(By.CssSelector("input[type=\"checkbox\"]")).Click();
I tried .Displayed and .Enabled and both these properties are always true.
Thanks for help.
To ensure that an action is performed on a click of a link or button, it is best to verify the resultant state of application. For eg. if I click on 'Log in' button after entering valid username and password, it will take me to my homepage, verify that homepage has loaded, else fail the click event. In case of invalid username/password, verify the warning message on login page itself.
To summarize, you have to validate the response to verify click event on any web element.
The least you can do is ensure that the element is clickable using ExpectedConditions.elementToBeClickable():
// In Java
WebDriverWait wait = new WebDriverWait(driver, timeOut);
wait.until(ExpectedConditions.elementToBeClickable(locator));
The code below is shown in firebug for the OK button in the popup of my application
<button id="ext-gen219" class="x-btn-text" type="button">
OK
</button>
Here the button id is randomly generated and also the position of ok button is not identifiable. Is there a way to click on the button by its text? Like the button contains a text called OK.
For Selenium IDE or Selenium RC, xpath=//button[contains(., 'OK')] ought to be a good locator.
I am going on the premise that the text of the popup boxes are not identical so I would recommend something like this:
List<IWebElement> dialogBox = driver.FindElements(By.Class("dialogBoxClass");
int buttonIndex = dialogBox.FindIndex(i => i.FindElement(By.Class("DisplayedTextElementClass").Text.Contains("some unique text here"));
dialogBox[buttonIndex].FindElement(By.ClassName("x-btn-text")).Click();
This captures the parent element of all the dialog boxes and then parses each object to find the index of the box you want and then clicks on the 'Ok' button in the correct object.
In case of a submit button this locator css=input:submit[value="OK"] should work. In case of a button element take css=button:contains("OK").