Element not found: Trying to verify a disabled button - testing

Trying to verify this button if it is disable on the page :
<div class="btn-group pull-right" xpath="1">
<div class="pull-right" style="">
<input type="submit" ng-disabled="registrationForm.$invalid|| vm.payload.ConfirmPassword!= vm.payload.Password|| vm.payload.ConfirmEmail!= vm.payload.Email|| vm.isAgreed== false|| vm.payload.GRecaptchaResponse== ''" class="btn btn-success btn-flat" value="Register and Continue" disabled="disabled" style="">
</div>
</div>
But every time I run it, it says Element not found:(using katalon) Tried adding delay()/ waitForElement but got the same error.
This is the xpath I am using :
//div[#class='btn-group pull-right']
WebUI.delay(10)
WebUI.verifyElementNotClickable(findTestObject('H3. Sign Up/H3.5 Providing correct details (Profile and Contact page) without checking Terms and Conditions and Captcha/Page_Demo Bookie (BETA)/Register And Continue Button'))
Below is the full error log
03-01-2019 01:39:17 PM Test Cases/H3. Sign Up/H3.5 Providing correct details (Profile and Contact page) without checking Terms and Conditions and Captcha
Elapsed time: 55.445s
Test Cases/H3. Sign Up/H3.5 Providing correct details (Profile and
Contact page) without checking Terms and Conditions and Captcha
FAILED. Reason: com.kms.katalon.core.exception.StepFailedException:
Unable to verify object 'Object Repository/H3. Sign Up/H3.5 Providing
correct details (Profile and Contact page) without checking Terms and
Conditions and Captcha/Page_Demo Bookie (BETA)/RegisterButton' to be
NOT clickable (Root cause:
com.kms.katalon.core.exception.StepFailedException: Web element with
id: 'Object Repository/H3. Sign Up/H3.5 Providing correct details
(Profile and Contact page) without checking Terms and Conditions and
Captcha/Page_Demo Bookie (BETA)/RegisterButton' located by 'By.xpath:
//*[#//div[#class='btn-group pull-right']//input =
'//div[#class="btn-group pull-right"]//input']' not found) at
com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
at
com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
at
com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
at
com.kms.katalon.core.webui.keyword.builtin.VerifyElementNotClickableKeyword.verifyElementNotClickable(VerifyElementNotClickableKeyword.groovy:96)
at
com.kms.katalon.core.webui.keyword.builtin.VerifyElementNotClickableKeyword.execute(VerifyElementNotClickableKeyword.groovy:67)
at
com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)
at
com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementNotClickable(WebUiBuiltInKeywords.groovy:591)
at
com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementNotClickable$4.call(Unknown
Source) at H3.5 Providing correct details (Profile and Contact page)
without checking Terms and Conditions and Captcha.run(H3.5 Providing
correct details (Profile and Contact page) without checking Terms and
Conditions and Captcha:86) at
com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194) at
com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at
com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:321)
at
com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:312)
at
com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:291)
at
com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:283)
at
com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:222)
at
com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at
com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown
Source) at
TempTestCase1551411555685.run(TempTestCase1551411555685.groovy:22)
Can anyone help me or share any idea on how to fix this?

You should target the input element with the following xpath:
//div[#class='btn-group pull-right']//input
or with css selector:
div.btn-group.pull-right input

Related

Selenium.Unable to enter username and password for a website

I have two input fields username and password. I am unable to locate and enter the inputs using selenium. Login button click also fails.
Please find the HTML
<div id="loginTable">
<form accept-charset="UTF-8" name="loginForm" method="POST" action="/cgi-bin/login">
<table>
<tbody>
<tr>
<td>User name:</td><td colspan="2"><input name="LOGIN"></td></tr><tr>
<td>Password:</td><td colspan="2"><input name="PWD" type="password"></td></tr><tr>
<td colspan="2"><button type="submit">Login</button></td></tr></tbody></table></form></div>
i have used below code lines,
driver.findElement(By.xpath("//[#id=\"loginTable\"]/form/table/tr[1]/td[2]/input")).sendKeys("test");
driver.findElement(By.name("LOGIN")).sendKeys("test");
WebElement userEntry=wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("LOGIN")));
userEntry.sendKeys("Test");
None of them are working.
Login button also not working.
Please help me.
The issue is your locator. You need something to identify the type of element you're looking for at the start (e.g. "//div[#id...." or "//*[#id...." if you want it as a wildcard) However you can simplify your locator to:
//input[#name='LOGIN']
Compound locators like the one you've attempted to use can be very brittle, as there are more elements from your code that could potentially change.

How to check the element titled AA E-mail Address is enabled or not

Hi I have the following html,
<td class="ms-crm-ReadField-Normal ms-crm-FieldLabel-RightAlign" id="agf_accountaccessemailaddressverified_c" title="AA E-mail Address Verified?">
<span class="ms-crm-InlineEditLabel">
<span class="ms-crm-InlineEditLabelText" style="max-width:200px;text-align:Right;width:80%;">
AA E-mail Address Verified?
</span>
<div class="ms-crm-Inline-GradientMask" style="display: none;">
</div>
</span>
</td>
I would like to see whether the checkbox AA E-mail Address Verified? as enabled or not using selenium webdriver.
I tried the following method :
bool check = driverIE.FindElement(By.CssSelector("#agf_accountaccessemailaddressverified_c > span:nth-child(1) > span:nth-child(1)")).Enabled;
or
bool check = driverIE.FindElement(By.Id("agf_accountaccessemailaddressverified_c")).Enabled;
Still getting the error that unable to find element.
Any help much appreciated?
I don't know Selenium, but a pure DOM way to find out if a field is locked would be through its lock icon.
For your field agf_accountaccessemailaddressverified there is a lock icon span tag with the id agf_accountaccessemailaddressverified_lock.
When locked it has the style display: block;,
When unlocked, it has the style display: none;
If you can check that with Selenium you should be able to test it properly.
The corresponding input doesn't get disabled, it just stays hidden in the background.
I'm not familiar with usage of it, but if Selenium behaves similarly to Chrome's F12 console, this will return the bool you need:
frames[0].Xrm.Page.getControl("agf_accountaccessemailaddressverified").getDisabled();
What I mean is, if you open the record in CRM, hit F12 and paste that in the console, it would return true or false depending on if the field is disabled or not. If Selenium runs javascript as it seems, it should not be that different.

Selenium Web driver - Locate by Class name

I want to click on the search auto complete BUTTON in a webmail application.
<button class="_n_r ms-bg-color-themeLight-hover o365button _n_s ms-bg-color-themeLighter ms-font-color-neutralPrimary ms-border-color-themePrimary" type="button" autoid="_n_4" aria-label="Activate Search Textbox">
<span class="_n_u owaimg ms-Icon--search ms-icon-font-size-20 ms-fcl-ts-b"/>
<span class="_n_t ms-font-weight-semilight ms-font-color-neutralPrimary">Search Mail and People</span>
When clicking the BUTTON, we get this INPUT
<input class="_is_x ms-font-weight-semibold ms-font-color-neutralPrimary ms-bg-color-themeLight ms-bg-color-themeLight-hover allowTextSelection textbox ms-font-s ms-fwt-sl ms-fcl-np ms-bcl-nta ms-bcl-nsa-h hideClearButton" autoid="_is_3" role="combobox" aria-autocomplete="list" aria-label="Search mail and people, type your search term then press enter to search."/>
I'm getting the following error while trying to use the class name from the input.
"The given selector _n_r ms-bg-color-themeLight-hover o365button _n_sms-bg-color-themeLighter ms-border-color-themeLighter is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: Compound class names not permitted"
We tried to use selenium IDE to fetch the value, but we are getting only the xpath. Is there any way to locate autocomplete search field with out using the xpath?
That's a LOT of classes on that INPUT. :) I would use a different attribute. I would start with one of these and see which one works for you. You didn't specify the language you are using so here's some code in Java.
driver.findElement(By.cssSelector("input[autoid='_is_3']"));
driver.findElement(By.cssSelector("input[aria-label='Search mail and people, type your search term then press enter to search.']"));
Quick note since you were asking about classes. You can go the classes route and use CSS Selectors to find them. A simple example.
<button class="one two">
You can find the BUTTON above using
driver.findElement(By.cssSelector("button.one.two"));
A period (.) indicates a CSS class so you would need a period before each class name. You don't necessarily need to include all the classes, only enough to make the element unique so you can locate it.
CSS Selectors reference
CSS Selectors tips

Selenium WebDriver : Not able find xpath for Paytm.com , Proceed button

I was trying to automate paytm.com site ,
Here i found Proceed button attribute has name but when i tried to use xpath checker for the name attribute , it was showing 13 matches but my question here is in the webpage from the UI level am not able to see 13 Proceed buttons instead only one Proceed button are present .
Even i tried with other attribute to find the xpath , but it showing more matches found.
Below is the HTML code for Proceed
<div class="msg-container">
<div class="btn-spinner" alt="Proceed to Recharge">
<div class="spinner hidden"></div>
<input class="btn proceed active" type="submit" data-express-text="Recharge Now" data-soft-block-text="Proceed anyway" data-default-text="Proceed" name="Proceed" value="Proceed" alt="Proceed to Recharge">
Can you please let me where am going wrong ?
This xpath returns 1 match for me
//form[#id='prepaidMobile']//input[#name='Proceed']
Also, if want use only //input[#name='Proceed'] you can get it from List of WebElements:
WebElement firstInput = driver.findElements(by.xpath("//input[#name='Proceed']"))[0];
This will work for you, I think:
driver.findElement(By.xpath("(//input[#name='Proceed'])[1]")));

Selenium Junit to find element

I am new to selenium.I am creating test script for duplicate registration into a website .When an error is displayed for duplicate registration i want to pass the testcase .
I am getting confused regarding the property of the webelement . I am not sure as to which field should i take or as how to write the findelement for the error image displayed.
Here is the HTML tag for the element image displayed:
<td>
<img src="images/bell.png">
</td>
This is for the text displayed along with error image :
<a onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['navigation'],'navigation:j_id322,navigation:j_id322','');}return false" style="color:#000000;" href="#">Found 1 patient(s) with same Patient Name, Gender and Age. Click here to view details</a>
Please help .Thanks
Based purely on the details provided, the following would work;
findElement(By.css("td>img[src='images/bell.png']")
and
findElement(By.css("a[onclick]")
However, I am sure that there is more context than this. Without the full html it is hard to give better solutions