Selenium with IE 11 - selenium

I am looking forward to get below help .
I was doing Test Automation for an application in Chrome with Xpaths . It was working well. But now I have a requirement to use the same suite to do cross browser testing in IE 11 .
Currently Using 2.39 IE Webdriver for Selenium . I am able to open browser but with my X path with which had my script ,not working with X path in IE 11 .
So here is my Question
Will I be able to use the Xpath used for chrome to do automation in IE 11
Also I found Execution is slower in IE 11 when compared to chrome
Do we have any X path Checker in IE 11 similarly in Chrome,Firefox .My requirement is to check all the x paths i used for chrome works in IE or not.But i dont know how should i check .
I understand from all the forums to go with CSS instead of X path , I can also do the same but just to understand is the X path same across Chrome and IE 11
Last i would like to understand a basic thing, when we say Xpath native support not present in ie browser -what do we mean
PS : I used Capabilities Ignorezoomsetting to true,require window focus to true ,native elements to false for Internet Explorer
Thanks in Advance
Html Code :
<html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<link rel="shortcut icon" href="favicon.ico?v=2" type="image/x-icon">
<title>-</title>
<style data-styled-components=""></style></head>
<body>
<div id="modal"></div>
<div id="app"><div class="Flex-kFpfAw ixXCQP" overflow="auto" display="flex" width="100%"><div class="NavBarIndicator__NavBarIndicatorHtml-ibzzfP jRSwXJ"><div class="NavBarIndicator__Indicator-eUunBf jITNXW"></div><div class="NavBarIndicator__IndicatorSettings-kgrEUt cPoXyp"></div></div><div class="Header__HeaderWrapper-cPhxZP hLpJId"><img class="_NavBarMenu__MenuIcon-gZnMef eTeQZD" src="/assets/images/menu.png"><div class="Flex-kFpfAw eaWcQg" width="100%" height="100%" display="flex"><div class="Flex-kFpfAw iuKZOD" width="200px" display="flex"><div class="Flex-kFpfAw cHydLU" cursor="pointer" width="0 auto" display="flex"><a class="AnchorLink__LinkWrapper-kpcMPo iKDWLW" color="#696969" font-size="14px" font-family="OpenSans">New Client</a></div><div class="Flex-kFpfAw cHydLU" cursor="pointer" width="0 auto" display="flex"><a class="AnchorLink__LinkWrapper-kpcMPo cJfTFc" color="#696969" font-size="14px" font-family="OpenSans">Existing Client</a></div></div></div></div><div class="Flex-kFpfAw eXWVrO" width="100%" display="flex"><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC jUObfx" name="basicDetailsAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dIFKrP" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">BASICS</div><div class="Accordion__ArrowContainer-jgNnsk joAlIe"></div></div><div class="Accordion__ContentContainer-bNGADI dUFUSp"><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Dropdown__DropdownContainer-iuXXkE eGcMOz" value=""><input class="Dropdown__InputField-XdsGe saBoZ" placeholder="" value=""><div class="Dropdown__FloatingLabel-dAuMht kobteq" value="">Title</div><div class="Dropdown__baseIconStyle-hZrHDI dGulpi" value=""></div><div class="Dropdown__DescOrErrorContainer-CVXZE cVVTfy"></div><div class="Dropdown__DropdownItemsContainer-ePnZKJ jIlnqS"></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">Christian Name</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">Given Name</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">Surname *</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Dropdown__DropdownContainer-iuXXkE eGcMOz" value=""><input class="Dropdown__InputField-XdsGe saBoZ" placeholder="" value=""><div class="Dropdown__FloatingLabel-dAuMht kobteq" value="">Marital Status</div><div class="Dropdown__baseIconStyle-hZrHDI dGulpi" value=""></div><div class="Dropdown__DescOrErrorContainer-CVXZE cVVTfy"></div><div class="Dropdown__DropdownItemsContainer-ePnZKJ jIlnqS"></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="date" value=""><div class="TextField__Label-hiPeUU dbpoGq" value=""></div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Dropdown__DropdownContainer-iuXXkE eGcMOz" value=""><input class="Dropdown__InputField-XdsGe saBoZ" placeholder="" value=""><div class="Dropdown__FloatingLabel-dAuMht kobteq" value="">Nationality</div><div class="Dropdown__baseIconStyle-hZrHDI dGulpi" value=""></div><div class="Dropdown__DescOrErrorContainer-CVXZE cVVTfy"></div><div class="Dropdown__DropdownItemsContainer-ePnZKJ jIlnqS"></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">NRIC or Passport number</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Flex-kFpfAw hhPbtN" height="80px" value="maleRadio" display="flex" width="100%"><div class="Radio__Header-iLHfxq epdwGX">Gender</div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Radio__Child-iQExMs iJGsOb" value="maleRadio">Male</div><div class="Radio__Child-iQExMs gETYuF" value="femaleRadio">Female</div></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="Flex-kFpfAw hhPbtN" height="80px" value="smokerYesRadio" display="flex" width="100%"><div class="Radio__Header-iLHfxq epdwGX">Smoker</div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Radio__Child-iQExMs iJGsOb" value="smokerYesRadio">Yes</div><div class="Radio__Child-iQExMs gETYuF" value="smokerNoRadio">No</div></div></div></div></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC iOrkBi" name="contactDetailsAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dRpCWJ" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">CONTACT</div><div class="Accordion__ArrowContainer-jgNnsk cmIaNs"></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC iOrkBi" name="educationDetailsAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dRpCWJ" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">EDUCATION & OCCUPATION</div><div class="Accordion__ArrowContainer-jgNnsk cmIaNs"></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC iOrkBi" name="othersAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dRpCWJ" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">OTHERS</div><div class="Accordion__ArrowContainer-jgNnsk cmIaNs"></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Flex-kFpfAw iJaRwj" width="100%" display="flex"><input class="Button__ButtonHtml-kIBguK eybnQU" type="submit" value="Back"><div class="Space-fYzrqg kpkBkk"></div><input class="Button__ButtonHtml-kIBguK kkGQYo" type="submit" value="Next"></div></div></div><div class="Overlay__OverlayHtml-fHbRtE iMIwlR"></div><div class="NavBarIndicator__NavBarIndicatorHtml-ibzzfP jRSwXJ"><div class="NavBarIndicator__Indicator-eUunBf jITNXW"></div><div class="NavBarIndicator__IndicatorSettings-kgrEUt cPoXyp"></div></div><div class="NavBar__NavBarHtml-AmdPv dLHKZS" color="red"><div class="NavBar__CloseButton-bbtqJM jXPpvT"><img class="NavBar__CloseIcon-kbJaLK hqvvWp" src="/assets/images/leftArrow.png"></div><a id="new-proposal" href="/client" style="text-decoration: none;"><div class="_NavBarButton__NavBarButtonHtml-jFBQvK hjgrnZ"><img class="_NavBarButton__NavBarIcon-koVGUP gjfdcG" src="/assets/images/addActive.png"><br><div class="_NavBarButton__Label-deFDME llMpjg">New Proposal</div></div></a><div class="_NavBarButton__NavBarButtonHtml-jFBQvK hjgrnZ"><img class="_NavBarButton__NavBarIcon-koVGUP gjfdcG" src="/assets/images/transaction.png"><br><div class="_NavBarButton__Label-deFDME ofuLs">Transactions</div></div><div class="_NavBarButton__NavBarButtonHtml-jFBQvK hjgrnZ"><img class="_NavBarButton__NavBarIcon-koVGUP gjfdcG" src="/assets/images/opportunity.png"><br><div class="_NavBarButton__Label-deFDME ofuLs">Opportunity</div></div><div class="NavBar__SettingsButton-gpFICj jHbjOK"><img class="NavBar__NavBarIcon-blvkXP fBFcQi" src="/assets/images/setting.png"><br><div class="NavBar__Label-eCmPLc cIziCb">Settings</div></div></div></div></div>
<script type="text/javascript" src="/assets/js/vendors~main.50b6700db1e18bf97471.js"></script><script type="text/javascript" src="/assets/js/main.50b6700db1e18bf97471.js"></script>
<!-- version: PROD --></body></html>

Will I be able to use the Xpath used for chrome to do automation in IE 11 :
The answer is No. use cssSelector , sometimes the xpath may work if it is not too much absolute. May be relative would do the job much easier.
Also I found Execution is slower in IE 11 when compared to chrome
There is no native support for xpath in IE, use again cssSelector to overcome this issue.
I understand from all the forums to go with CSS instead of X path , I can also do the same but just to understand is the X path same across Chrome and IE 11 .
No it is not same , again go with cssSelector
Last i would like to understand a basic thing, when we say Xpath native support not present in ie browser -what do we mean
It means that IE engine does not have anything for xpath , IE has to use 3rd party to get along with xpath.
Hope this will be helpful.

Related

How can i send keys to an iframe when iframe is the only element in the iframe

I have this iframe which is for inputting the card number.
I am trying this in chrome headless mode
<iframe hspace="0" vspace="0" frameborder="0" scrolling="no" allowtransparency="true" marginwidth="0" marginheight="0"
html inside the iframe with #document
#document
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>*{margin:0;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box;border:none;background-color:transparent}body,form,input{position:absolute;top:0;left:0;height:100%;width:100%}label{position:absolute;left:-9999px}:focus{outline:0}::-ms-clear,input::-ms-clear{display:none}.autocomplete,.field-description,.focus-helper{opacity:0;pointer-events:none;width:1px;height:1px;left:-1px;z-index:-1}.autocomplete{width:2px;height:2px;left:-2px}</style><style></style></head><body marginwidth="0" marginheight="0"><script src="iframe.min.js"></script><form><input class="focus-helper start" tabindex="0" readonly="" aria-hidden="true" autocomplete="off" autocompletetype="off" x-autocompletetype="off"><input name="number" type="tel" autocorrect="off" autocapitalize="none" spellcheck="false" aria-invalid="false" aria-label="Card number" maxlength="22" autocomplete="cc-number" autocompletetype="cc-number" x-autocompletetype="cc-number" placeholder=" " aria-placeholder=" " class="invalid"><input type="text" name="name" id="name-autocomplete" class="autocomplete" autocomplete="cc-name" autocompletetype="cc-name" x-autocompletetype="cc-name" tabindex="-1" aria-hidden="true"><input type="text" name="expirationMonth" id="expirationMonth-autocomplete" class="autocomplete" autocomplete="cc-exp-month" autocompletetype="cc-exp-month" x-autocompletetype="cc-exp-month" tabindex="-1" aria-hidden="true"><input type="text" name="expirationYear" id="expirationYear-autocomplete" class="autocomplete" autocomplete="cc-exp-year" autocompletetype="cc-exp-year" x-autocompletetype="cc-exp-year" tabindex="-1" aria-hidden="true"><input class="focus-helper end" tabindex="0" readonly="" aria-hidden="true" autocomplete="off" autocompletetype="off" x-autocompletetype="off"></form></body></html>
Write the Xpath for that iframe like the below. As you mentioned
I have this iframe which is for inputting the card number.
so there is an attribute for for card number.
//iframe[#attribute='value']
Eg:
driver.switchTo().frame("iframe");
WebElement ele = driver.findElement(By.xpath("//iframe[#attribute='value']"));
ele.sendKeys('Text');
or
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[#attribute='value']")));
WebElement inputtext = driver.findElement(By.xpath("//input[#attribute='value']"));
inputtext.sendKeys("text");
Hope this answer your question, please share the HTML from inspect element if this does not answer your question.

Why doesn't the search for an element that does not contain a value work in xpath?

A piece of html page that I have:
<html lang="ru">
<body>
<form name="substitutionFM" class="form-data" onsubmit="return !1">
<input name="message" id="message" type="hidden" value="error.password.invalid">
</form>
<div _ngcontent-c17="" class="content">
<input _ngcontent-c15="" automation-id="bui-primitive-textfield__native-input" class="input bui-autofill ng-untouched ng-pristine ng-valid ng-star-inserted" aria-placeholder="" id="bui_01584205838454" type="text" tabindex="0" inputmode="numeric" x-inputmode="numeric" aria-describedby="bui_01584205838454_described-by" style="padding-left: 16px; padding-right: 16px;">
</div>
</body>
</html>
My xpath that I am trying to find the elements I want:
.//input/#*[(contains(., "otp") or contains(., "ode") or contains(., "assword") or contains(., "numeric")) and not(contains(., "hidden"))]/..
As you can see, I don't want to find hidden elements, but that doesn't work, and both elements are in the browser and in the selenium, but I only need the second one. How can I fix this?
Try this one
'//input[#*[contains(., "otp") or contains(., "ode") or contains(., "assword") or contains(., "numeric")] and not(#*[contains(., "hidden")])]'

Why can I click an input with type=radio of a h:selectOneRadio, but not one of a p:selectOneRadio with Graphene/Selenium?

A h:selectOneRadio results in <input type="radio"> in a table and p:selectOneRadio in <input type="radio"> in a table with some divs around the input. The id for both is [form id]:[selectOneRadio id]:[option number] which I can use successfully for the plain JSF in a Graphene functional test when accessing it with #FindBy(id="[...]") whereas the PrimeFaces variant fails due to org.openqa.selenium.ElementNotInteractableException. Investigating the generated HTML I don't see the difference
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/34696ceb-eeaa-4b35-88dd-f3c8fc5901bf/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo">
<link type="text/css" rel="stylesheet" href="/34696ceb-eeaa-4b35-88dd-f3c8fc5901bf/javax.faces.resource/primefaces.css.xhtml;jsessionid=48ca919d0b7e89661f92149ac321?ln=primefaces&v=5.0">
<script type="text/javascript" src="/34696ceb-eeaa-4b35-88dd-f3c8fc5901bf/javax.faces.resource/jquery/jquery.js.xhtml;jsessionid=48ca919d0b7e89661f92149ac321?ln=primefaces&v=5.0"></script>
<script type="text/javascript" src="/34696ceb-eeaa-4b35-88dd-f3c8fc5901bf/javax.faces.resource/primefaces.js.xhtml;jsessionid=48ca919d0b7e89661f92149ac321?ln=primefaces&v=5.0"></script>
<title>Facelet Title</title>
</head>
<body>
<form id="mainForm" name="mainForm" method="post" action="/34696ceb-eeaa-4b35-88dd-f3c8fc5901bf/index.xhtml;jsessionid=48ca919d0b7e89661f92149ac321" enctype="application/x-www-form-urlencoded">
<input name="mainForm" value="mainForm" type="hidden">
<table id="mainForm:mainSelectOneRadio">
<tbody>
<tr>
<td>
<input name="mainForm:mainSelectOneRadio" id="mainForm:mainSelectOneRadio:0" value="a" type="radio">
<label for="mainForm:mainSelectOneRadio:0"> a</label>
</td>
<td>
<input name="mainForm:mainSelectOneRadio" id="mainForm:mainSelectOneRadio:1" value="b" type="radio">
<label for="mainForm:mainSelectOneRadio:1"> b</label>
</td>
<td>
<input name="mainForm:mainSelectOneRadio" id="mainForm:mainSelectOneRadio:2" value="c" type="radio">
<label for="mainForm:mainSelectOneRadio:2"> c</label>
</td>
</tr>
</tbody>
</table>
<table id="mainForm:mainSelectOneRadioPrime" class="ui-selectoneradio ui-widget">
<tbody>
<tr>
<td>
<div class="ui-radiobutton ui-widget">
<div class="ui-helper-hidden-accessible">
<input id="mainForm:mainSelectOneRadioPrime:0" name="mainForm:mainSelectOneRadioPrime" value="aPrime" type="radio">
</div>
<div class="ui-radiobutton-box ui-widget ui-corner-all ui-state-default"><span class="ui-radiobutton-icon ui-icon ui-icon-blank"></span>
</div>
</div>
</td>
<td>
<label for="mainForm:mainSelectOneRadioPrime:0">aPrime</label>
</td>
<td>
<div class="ui-radiobutton ui-widget">
<div class="ui-helper-hidden-accessible">
<input id="mainForm:mainSelectOneRadioPrime:1" name="mainForm:mainSelectOneRadioPrime" value="bPrime" type="radio">
</div>
<div class="ui-radiobutton-box ui-widget ui-corner-all ui-state-default"><span class="ui-radiobutton-icon ui-icon ui-icon-blank"></span>
</div>
</div>
</td>
<td>
<label for="mainForm:mainSelectOneRadioPrime:1">bPrime</label>
</td>
<td>
<div class="ui-radiobutton ui-widget">
<div class="ui-helper-hidden-accessible">
<input id="mainForm:mainSelectOneRadioPrime:2" name="mainForm:mainSelectOneRadioPrime" value="cPrime" type="radio">
</div>
<div class="ui-radiobutton-box ui-widget ui-corner-all ui-state-default"><span class="ui-radiobutton-icon ui-icon ui-icon-blank"></span>
</div>
</div>
</td>
<td>
<label for="mainForm:mainSelectOneRadioPrime:2">cPrime</label>
</td>
</tr>
</tbody>
</table>
<input name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="-485558793831512050:990657069126697889" autocomplete="off" type="hidden">
</form>
</body>
</html>
nor do I if I deploy the application on Payara 4.1.2 or any other reason for the ElementNotInteractableException.
The access is done with
#RunWith(Arquillian.class)
public class MyManagedBeanTest {
private static final String WEBAPP_SRC = "src/main/webapp";
private final static Logger LOGGER = LoggerFactory.getLogger(MyManagedBeanTest.class);
#Deployment(testable = false)
public static Archive<?> createDeployment0() throws TransformerException, XPathExpressionException, ParserConfigurationException, SAXException, IOException {
WebArchive retValue = ShrinkWrap.create(WebArchive.class)
.add(EmptyAsset.INSTANCE, "beans.xml")
.addClasses(MyManagedBean.class)
.addAsWebInfResource(
new StringAsset("<faces-config version=\"2.0\"/>"),
"faces-config.xml");
Maven.configureResolver().workOffline().resolve("richtercloud:graphene-click-input-radio:war:1.0-SNAPSHOT").withoutTransitivity().asList(JavaArchive.class).forEach(dependency -> retValue.addAsLibrary(dependency));
//add all webapp resources
retValue.merge(ShrinkWrap.create(GenericArchive.class)
.as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC)
.as(GenericArchive.class), "/", Filters.include(".*\\.(xhtml|css|js|png)$"));
ByteArrayOutputStream archiveContentOutputStream = new ByteArrayOutputStream();
retValue.writeTo(archiveContentOutputStream, Formatters.VERBOSE);
LOGGER.info(archiveContentOutputStream.toString());
return retValue;
}
#Drone
private WebDriver browser;
#ArquillianResource
private URL deploymentUrl;
#FindBy(id = "mainForm:mainSelectOneRadio:0")
private WebElement mainSelectOneRadioOption0;
#FindBy(id = "mainForm:mainSelectOneRadioPrime:0")
private WebElement mainSelectOneRadioPrimeOption0;
#Test
public void testAll() {
browser.get(deploymentUrl.toExternalForm()+"index.xhtml");
LOGGER.debug(browser.getPageSource());
mainSelectOneRadioOption0.click();
mainSelectOneRadioPrimeOption0.click();
}
}
I'm searching for a solution which triggers JSF action methods and AJAX listeners!
I'd be interested in a generic approach as well, e.g. p:selectOneButton produces
<div id="mainForm:mainSelectOneButtonPrime" class="ui-selectonebutton ui-buttonset ui-widget ui-corner-all">
<div class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left">
<input id="mainForm:mainSelectOneButtonPrime:0" name="mainForm:mainSelectOneButtonPrime" value="aPrime" class="ui-helper-hidden" type="radio">
<span class="ui-button-text ui-c">aPrime</span>
</div>
<div class="ui-button ui-widget ui-state-default ui-button-text-only">
<input id="mainForm:mainSelectOneButtonPrime:1" name="mainForm:mainSelectOneButtonPrime" value="bPrime" class="ui-helper-hidden" type="radio">
<span class="ui-button-text ui-c">bPrime</span>
</div>
<div class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right">
<input id="mainForm:mainSelectOneButtonPrime:2" name="mainForm:mainSelectOneButtonPrime" value="cPrime" class="ui-helper-hidden" type="radio">
<span class="ui-button-text ui-c">cPrime</span>
</div>
</div>
<input name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="-5130093024933213812:2291815208147638618" autocomplete="off" type="hidden">
which doesn't seem to have anything in common with the HTML generated for p:selectOneRadio at first sight. Maybe there's a trick.
I'm using PrimeFaces 6.1.
ui-helper-hidden-accessible is a JQuery layout helper to hide items visually. The radio button you see is actually the parent element, <div class="ui-radiobutton ui-widget">.
The problem can be resolved by clicking on the radio button label. The 'for` attribute put the focus on the input label associated with it
#FindBy(css = "[for='mainForm:mainSelectOneRadioPrime:0']")
private WebElement mainSelectOneRadioPrimeOption0;
#Guy has the right answer.
The issue here is that PrimeFaces is applying its own styling on top of the HTML which is covering the element you are trying to click.
Selenium checks that the targeted element mainForm:mainSelectOneRadio:0 receives the events when the element on top is clicked. But in this case the overlay is done with a sibling container which is not an descendant of targeted element. Thus Selenium assumes that the element will not receive the events and raises an ElementNotInteractableException (see event bubbling and propagation).
You can clearly see the issue by visiting oneRadio.xhtml and by inspecting the radio button with a right click. You'll see that the selected DOM element and the <input> are located in two different branches of the DOM tree.
To overcome this issue, either click the label since it has no overlay (see solution from #Guy). The label has the for attribute which mean that all the events are forwarded to the element assigned to for which is the targeted <input>.
You could also directly click the overlay. Though, you'll have to use an XPath to express the relationship.
Parent of parent of the targeted <input> :
#FindBy(xpath = "id('mainForm:mainSelectOneRadioPrime:2')/../..")
private WebElement mainSelectOneRadioPrimeOption0;
Or first <td> having the targeted <input> :
#FindBy(xpath = "//td[.//input[#id='mainForm:mainSelectOneRadioPrime:2']]")
private WebElement mainSelectOneRadioPrimeOption0;

Need unique field to identify using Selenium WebDriver

I need to find the the unique field to identify the search box and enter text in it.
<style type="text/css">
</head>
<body style="min-height: 81px;">
<div class="shared-page" data-cid="view221" data-view="views/shared/Page" data-render-time="0.02">
<a class="navSkip" tabindex="1" href="#navSkip">Screen reader users, click here to skip the navigation bar</a>
<header role="banner">
<a id="navSkip"></a>
<div class="main-section-body" role="main">
<div class="timeline" data-cid="view4947" data-view="views/timeline/Master" data-render-time="0.107">
<div class="section-padded section-header">
<div class="timeline-title" data-cid="view5085" data-view="views/timeline/Title" data-render-time="0.001">
<div class="search-bar-wrapper shared-searchbar" data-cid="view4948" data-view="views/shared/searchbar/Master" data-render-time="0.104">
<form class="search-form" action="" method="get">
<table class="search-bar search-bar-primary">
<tbody>
<tr>
<td class="search-input" width="100%">
<div id="search" class="shared-searchbar-input" data-cid="view4949" data-view="views/shared/searchbar/Input" data-render-time="0.002">
<div class="search-field-background"> </div>
<div class="search-field-wrapper">
<label class="placeholder-text" for="397271.5897375417" style="display: block;">enter search here...</label>
<textarea id="397271.5897375417" class="search-field" autocapitalize="off" autocorrect="off" spellcheck="false" name="q" rows="1"></textarea>
textarea is the field related to the search box. I tried using class, name but it says unable to locate element, the numeric id too is dynamic. Please let me know what to use in this case.
It should be possible to find this element by class name
in ruby:
driver.find_element(:class, "search-field")
or in java:
driver.findElement(By.className("search-field"));
Following xpath should work:
//div[#id='search']//textarea[#class='search-field']
If the <textarea> is only one, you can search with
driver.findElement(By.tagName("textarea"));
Use xpath,
driver.findElement(By.xpath("//textarea[#class='search-field']"));
Or
driver.findElement(By.name("q"));

Create a bar chart in dojo with the series values to be taken from the users via the textboxes

I wish to develope an application which allows the user to set the values for the series and also the labels for the axes via input like textboxes below is the code i tried,
<html>
<head>
<title>Chart Demo</title>
<style type="text/css">
#import "../dijit/themes/tundra/tundra.css";
#import "../dojo/resources/dojo.css"
</style>
<SCRIPT type=text/javascript src="dojo/dojo.js" djConfig="isDebug: true"></SCRIPT>
<script type="text/javascript">
//dojo.require("dojo.event.*");
dojo.require("dojo.parser");
dojo.require("dijit.layout.SplitContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dojox.charting.Chart2D");
//dojo.require("dojo.widget.*");
//dojo.require("dojo.widget.Button");
makeCharts = function() {
var val1=dijit.byid('val1').get('value');
var val2=dijit.byid('val2').get('value');
var val3=dijit.byid('val3').get('value');
var val4=dijit.byid('val4').get('value');
var chart1 = new dojox.charting.Chart2D("simplechart");
chart1.addPlot("default", {type: "Columns", gap: 5});
chart1.addAxis("x",{
labels: [
{value: 0, text: "one"},
{value: 1, text: "two"},
{value: 2, text: "three"},
{value: 3, text: "four"}]}
);
chart1.addAxis("y", {vertical: true});
chart1.addSeries("Series 1", [val1, val2, val3, val4]);
chart1.render();
};
</script>
</head>
<body class="tundra">
<div dojoType="dijit.layout.SplitContainer" orientation="horizontal"
sizerWidth="10" activeSizing="true"
style="border: 1px solid #FF00FF; width: 600px; height: 205px;">
<div dojoType="dijit.layout.ContentPane" sizeMin="10" sizeShare="10">
<p><b>Enter the required details for chart</b></p>
<form method="post" id="dataForm" name="dataForm>
<table>
<tr>
<td><label>X-axis</label></td>
<td><input type="text" trim="true" dojoType="dijit.form.TextBox"
value="" name="x" id="tx"/></td>
</tr>
<tr>
<td><label>y-axis</label></td>
<td><input type="text" trim="true" dojoType="dijit.form.TextBox"
value="" name="y" id="ty"/></td>
</tr>
<tr>
<td><label>value1</label></td>
<td><input dojoType="dijit.form.NumberSpinner"
value="0"
smallDelta="1"
constraints="{min:0,max:1000,places:0}"
maxlength="20"
id="val1"></td>
</tr>
<tr>
<td><label>value2</label></td>
<td><input dojoType="dijit.form.NumberSpinner"
value="0"
smallDelta="1"
constraints="{min:0,max:1000,places:0}"
maxlength="20"
id="val2"></td>
</tr>
<tr>
<td><label>value3</label></td>
<td><input dojoType="dijit.form.NumberSpinner"
value="0"
smallDelta="1"
constraints="{min:0,max:1000,places:0}"
maxlength="20"
id="val3"></td>
</tr>
<tr>
<td><label>value4</label></td>
<td><input dojoType="dijit.form.NumberSpinner"
value="0"
smallDelta="1"
constraints="{min:0,max:1000,places:0}"
maxlength="20"
id="val4"></td>
</tr>
<tr>
<td colspan="2">
<input name="Submit" type="button" id="Submit" onclick="makeCharts();" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
<div dojoType="dijit.layout.ContentPane" sizeMin="10" sizeShare="10" id=simplechart>
</div>
</div>
</body>
</html>
but this code is generating some errors, which i am unable to debug....
Please help
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; MS-RTC LM 8)
Timestamp: Thu, 14 Apr 2011 05:51:38 UTC
Message: Object doesn't support this property or method
Line: 25
Char: 2
Code: 0
URI: file:///D:/dojo%20new/dojo-release-1.6.0-src/trial1.html
Since you've not formatted your question properly and have left out pretty much all the relevant parts of your HTML, it's difficult to tell, but there are a few things I notice right off the bat:
Here you are missing a quotation mark at the end:
<form method="post" id="dataForm" name="dataForm>
Dijit's byId method uses capital i (dijit.byId(...)), so you need to change these four lines.
var val1=dijit.byid('val1').get('value');
var val2=dijit.byid('val2').get('value');
var val3=dijit.byid('val3').get('value');
var val4=dijit.byid('val4').get('value');
Fix this and see if it works.