how to click driver find_element_by_xpath - not working - python-3.x

<div id="primefacesmessagedlg" class="ui-message-dialog ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ui-hidden-container" role="dialog" aria-labelledby="primefacesmessagedlg_title" aria-hidden="false" style="width: auto; height: auto; left: 256.5px; top: 255px; z-index: 1001; display: block;" aria-live="polite">
<div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top ui-draggable-handle">
<span class="ui-dialog-title">Alert!!</span>
<a class="ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all" href="#" role="button">
<span class="ui-icon ui-icon-closethick"></span>
</a>
</div>
<div class="ui-dialog-content ui-widget-content" style="height: auto;"><span class="ui-dialog-message ui-messages-info-icon"></span>OTP has been generated and sent to registered Mobile No:XXXXXX0002 with reference number 891</div>
</div>
How to click on this X icon using selenium python code
<div id="primefacesmessagedlg" class="ui-message-dialog ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ui-hidden-container" role="dialog" aria-labelledby="primefacesmessagedlg_title" aria-hidden="false" style="width: auto; height: auto; left: 256.5px; top: 255px; z-index: 1001; display: block;" aria-live="polite"><div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top ui-draggable-handle"><span class="ui-dialog-title">Alert!!</span><a class="ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all" href="#" role="button"><span class="ui-icon ui-icon-closethick"></span></a></div><div class="ui-dialog-content ui-widget-content" style="height: auto;"><span class="ui-dialog-message ui-messages-info-icon"></span>reference number 891</div></div>
I tried with this code but I got error
Message: element not interactable

In your code
elem = driver.find_element_by_xpath('//a[#class="ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all"]').click()
you have used "Click" method, it won't return anything.
Just use this driver.find_element_by_xpath('//a[#class="ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all"]').click()

You can try to add waiting
button = WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.dismiss')))
button.click()
Or try to use js click
element = driver.find_element_by_xpath('//a[#class="ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all"]')
def js_click(self, element):
driver.execute_script("arguments[0].click();", element)

Related

How to click on the element using the innerText text of a class in Selenium vba

I am willing to get the innerText and click on it. The text is Customer Service Inquiry.
I have tried:
.FindElementsByXPath("//*[text()[contains(.listItem, 'Customer Service Inquiry')]]").Click
This does not work as it gives error that it is not a valid xpath expression
Further, this works but I am wanting to click by what the inner text says.
.FindElementByXPath("//*[#id='listFav_ALLOUTSECURITY0000000000000000008276_APP_P4210_W4210E_PSG0021_20']").click
The html
<div id="listContentHolder"> == $0 > <div class="carolist" id="listOCL" slot="0" style="height: 57px; top: #px;">.</div> > <div class="carolist" id="listRecipts" slot="1" style="height: 57px; top: 57px;">.</div> <div class="caroList" id="listFav" slot="2" style="height: 153px; top: 114px;"> > <div class="listHeader expanded" id="listFavHeader" oncontextmenu="javascript:CARO.updateDropdownMenuView(this,event);jdebebGUIdoToggleSubMenu(this,'caroTabContextMenu', event, true)
;" toplistitem="false">.</div> <div id="listFavouter" class="listContentOuter" style="height: 128px;"> <div id="listFavInner" class="listContentInner" style="height: 128px; top: Opx;">
<div class="listItem" id="listFav_manageFavs" aria-labelledby="appCaption_fav_manageFavs" role="link" tabindex="0" style="user-select: none; top: Opx;">.</div> > <div class="listItem" id="listFav_ALLOUTSECURITY0000000000000000008582_APP_P4210_W4210E_PSG0099_10" aria-labelledby="appCaption_fav_ALLOUTSECURITY0000000000000000008582_APP_P4210_W 4210E_PSG0099_10" role="link" tabindex="0" style="user-select: none; top: 32px;">.</div>
<div class="listItem" id="listFav_ALLOUTSECURITY0000000000000000008276_APP_P4210_W4210E_PSG0021_20" aria-labelledby="appCaption_fav_ALLOUTSECURITY0000000000000000008276_APP_P4210_W 4210E_PSG0021_20" role="link" tabindex="0" style="user-select: none; top: 64px;"> <table class="listItem">
<tbody>
<tr> >
<td class="listIcon">.</td>
<td class="listText">Customer Service Inquiry</td>
</tr>
</tbody>
</table>
</div>
<div class="listItem" id="listFav_21343ad6_1803cf57c8c__7ffeE1PDJAS3__APP_P41026_W41026E_PSA0001_30" aria-labelledby="appCaption_fav_21343ad6_1803cf57c8c__7ffeE1PDJAS3_APP_P41026_ W41026E_PSA0001_30" role="link" tabindex="0" style="user-select: none; top: 96px;">.</div> </div> <a class="panControl up" necessary="false" style></a>
<a class="panControl down" necessary="false" stylex/a> </div> </div> </div>
To click on the element with text as Customer Service Inquiry you can use either of the following locator strategies:
Using FindElementByXPath and only the innerText:
.FindElementByXPath("//td[text()='Customer Service Inquiry']").click
Using FindElementByXPath along with the class and the innerText:
.FindElementByXPath("//td[#class='listText' and text()='Customer Service Inquiry']").click

Negative margin-left to hide left side of element

I need to use a left negative margin so that my element left side would disappear on the left side of the screen.
I tried using position relative but it doesn't work...
<div class="card" id="historyCard">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" id="historyBtn" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
היסטוריה
<img src="images/clock.png" id="hamNavHistoryImg" width="87" height="87"/>
</button>
</h5>
</div></div>
#historyCard {
background-color: #ffb59b;
border-bottom-right-radius: 50%;
border-top-right-radius: 50%;
padding: 30px 0 80px 0;
margin-top: 10px;
z-index: 5;
margin-left:-50px;
}
screenshot

Audio on website not playing fully - stops and repeats

I run a church website, where we upload the audio from each week's message. I have a few folks who are telling me that on the website, the audio file will play for a few minutes, but then it unexpectedly restarts to the beginning. They can't listen to any of the audio files from start to finish (they run 15-25 minutes). Any suggestions as to what could cause this issue?
The audio files are pushed to iTunes in a podcast, and no one has any trouble with the audio files playing in full on iTunes. The issue is only on the website.
I have not been able to replicate the issue on my computer, so at first I thought it was just one person's problem. However, I've had a few different people tell me they have encountered this problem. You're welcome to test the issue yourself - wsumc.com/multimedia-archive/broken-nation/
Thanks for any help!
<div class="audio-container">
<span class="mejs-offscreen">Audio Player</span>
<div id="mep_0" class="mejs-container wp-audio-shortcode mejs-audio mejs-hide-cues mejs-container-keyboard-inactive" tabindex="0" role="application" aria-label="Audio Player" style="width: 280px; height: 40px; min-width: 169px;">
<div class="mejs-inner">
<div class="mejs-mediaelement">
<mediaelementwrapper id="audio-8556-1"><audio class="wp-audio-shortcode" id="audio-8556-1_html5" preload="none" style="width: 100%; max-width: 100%; height: 100%;" src="http://wsumc.com/wp-content/uploads/Broken-Nation.mp3?_=1">http://wsumc.com/wp-content/uploads/Broken-Nation.mp3</audio></mediaelementwrapper></div>
<div class="mejs-layers">
<div class="mejs-poster mejs-layer" style="display: none; width: 100%; height: 100%;"></div></div>
<div class="mejs-controls">
<div class="mejs-button mejs-playpause-button mejs-play"><button type="button" aria-controls="mep_0" title="Play" aria-label="Play" tabindex="0"></button></div>
<div class="mejs-time mejs-currenttime-container" role="timer" aria-live="off"><span class="mejs-currenttime">00:00</span></div>
<div class="mejs-time-rail" style="width: 145px;">
<span class="mejs-time-total mejs-time-slider" role="slider" tabindex="0" aria-label="Time Slider" aria-valuemin="0" aria-valuemax="NaN" aria-valuenow="0" aria-valuetext="00:00">
<span class="mejs-time-buffering" style="display: none;"></span>
<span class="mejs-time-loaded"></span>
<span class="mejs-time-current"></span><span class="mejs-time-hovered no-hover"></span>
<span class="mejs-time-handle">
<span class="mejs-time-handle-content"></span></span>
<span class="mejs-time-float" style="display: none; left: 0px;">
<span class="mejs-time-float-current">00:00</span>
<span class="mejs-time-float-corner"></span></span></span></div>
<div class="mejs-time mejs-duration-container">
<span class="mejs-duration">00:00</span></div>
<div class="mejs-button mejs-volume-button mejs-mute">
<button type="button" aria-controls="mep_0" title="Mute" aria-label="Mute" tabindex="0"></button></div><a class="mejs-horizontal-volume-slider" href="javascript:void(0);" aria-label="Volume Slider" aria-valuemin="0" aria-valuemax="100" role="slider" style="display: block;">
<span class="mejs-offscreen">Use Up/Down Arrow keys to increase or decrease volume.</span><div class="mejs-horizontal-volume-total">
<div class="mejs-horizontal-volume-current" style="left: 0px; width: 100%;"></div>
<div class="mejs-horizontal-volume-handle" style="left: 100%;"></div></div></a></div></div></div></div>

"Element is not currently visible and so may not be interacted with" Watir

Facing the issue when the code is executed in test script. the same code executes fine in irb
#browser.div(:class=>/DownArrowButton/).when_present.click #works fine, dropdown
popup = #browser.div(:id=>'pgObjectSelector_Popover')
popup.text_fields(:id=>/dijit_form_TextBox_/).select{|s| s.visible?}[0].when_present.set('ethernet')
While setting the key the widget gets closed with an error:
Element is not currently visible and so may not be interacted with
[remote server] file:///C:/Users/suchanna/AppData/Local/Temp/webdriver-profile20150319-30448-a96p5v/extensions/fxdriver#googl
ecode.com/components/command-processor.js:8991:in `fxdriver.preconditions.visible'
Please help me out for the above problem
Html:
<div id="pgObjectSelector_Popover" class="xwtPopover dijitTooltipDialog xwt_BasePickerPopover dijitTooltipABLeft dijitTooltipBelow" wairole="presentation" widgetid="pgObjectSelector_Popover" style="top: 0px; display: none;">
<div class="dijitTooltipContainer" data-dojo-attach-event="onkeypress: _onKey" wairole="dialog" waistate="labelledby-pgObjectSelector_Popover_title" data-dojo-attach-point="_outsideContainer" style="">
<table class="xwtPopoverMenuBar" cellspacing="0" cellpadding="0" data-dojo-attach-point="menuBar" wairole="presentation"></table>
<div class="xwtPopoverPadding" data-dojo-attach-point="_paddingContainer">
<div class="dijitTooltipContents dijitTooltipFocusNode" tabindex="-1" data-dojo-attach-point="_scrollBox" style="overflow-x: hidden;">
<table class="xwtPopoverTable" wairole="presentation">
<tbody>
<tr>
<td wairole="presentation">
<div class="xwtPopoverContainer" wairole="presentation" tabindex="-1" data-dojo-attach-point="containerNode">
<div id="dijit_layout_BorderContainer_0" class="dijitBorderContainerNoGutter dijitContainer dijitLayoutContainer" widgetid="dijit_layout_BorderContainer_0" style="padding: 0px; width: 275px; height: 300px;">
<div id="dijit_layout_ContentPane_1" class="dijitContentPane dijitBorderContainerNoGutter-child dijitBor…nerNoGutterPane dijitAlignCenter dijitContentPaneSingleChild" widgetid="dijit_layout_ContentPane_1" style="left: 0px; top: 0px; position: absolute; width: 275px; height: 300px;">
<div id="pgObjectSelector_osInstance" class="xwtobjectselector" minheight="100" minwidth="220" data-dojo-attach-point="osNode" widgetid="pgObjectSelector_osInstance" style="cursor: default; width: 273px; height: 298px;">
<div id="xwt_widget_objectselector__Titlebar_0" class="xwtOsTitlebar" minwidth="100" data-dojo-attach-point="titleBar" widgetid="xwt_widget_objectselector__Titlebar_0"></div>
<div class="xwtobjectselectorcontents xwtOSDataReady" data-dojo-attach-point="osContents">
<div class="xwtObjectSelectorToolbars" data-dojo-attach-point="toolbars">
<div id="xwt_widget_objectselector__ObjectSelectorToolbar_0" class="xwtOsToolbar" data-dojo-attach-point="ButtonToolbar" minwidth="100" data-dojo-type="xwt.widget.toolbar.LayoutToolbar" widgetid="xwt_widget_objectselector__ObjectSelectorToolbar_0" style="display: none;"></div>
<div id="xwt_widget_filtertoolbar_FilterToolbar_0" class="xwtFilterToolbar" widgetid="xwt_widget_filtertoolbar_FilterToolbar_0" style="width: 273px;">
<div class="xwtFilterbarLeft" data-dojo-attach-point="SearchLeftGroup"></div>
<div class="xwtFilterbarCenter" data-dojo-attach-point="SearchCenterGroup">
<div class="xwtFilterSearchIcon icon-cisco-search" title="Search" tabindex="0" data-dojo-attach-point="searchButton">
<div class="xwt-ButtonSearchTextHighContrast" data-dojo-attach-point="searchTextHighCont"></div>
<span class="xwtFilterSearchText" data-dojo-attach-point="searchText"></span>
</div>
<span class="dijit dijitReset dijitInline xwtFilterDownButton xwtFilterDownIcon xwtFilterbarDropdownOff" widgetid="dijit_form_DropDownButton_3">
<span class="dijitReset dijitInline dijitButtonNode" data-dojo-attach-point="_buttonNode" data-dojo-attach-event="ondijitclick:__onClick"></span>
<input class="dijitOffScreen" type="button" aria-hidden="true" role="presentation" data-dojo-attach-point="valueNode" data-dojo-attach-event="onclick:_onClick" tabindex="-1" value=""></input>
</span>
<div id="widget_dijit_form_TextBox_1" class="dijit dijitReset dijitInline dijitLeft xwtFilterSearchBox dijitTextBox" role="presentation" widgetid="dijit_form_TextBox_1" style="width: 185px;">
<div class="dijitReset dijitInputField dijitInputContainer">
<input id="dijit_form_TextBox_1" class="dijitReset dijitInputInner" type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" tabindex="0" value=""></input>
<span class="dijitPlaceHolder dijitInputField">
Search All
</span>
</div>
</div>
<div class="xwtFilterClearIcon" data-dojo-attach-event="ondijitclick: _clearIconClicked" tabindex="0" data-dojo-attach-point="closeButton"></div>
<div class="xwtClear"></div>
</div>
<div class="xwtFilterbarRight" data-dojo-attach-point="SearchRightGroup"></div>
<div class="xwtAdvFilterButton" data-dojo-attach-point="advancedFilter"></div>
<div class="xwtClear"></div>
</div>
<div id="dijit_layout_ContentPane_0" class="dijitContentPane xwtOsScopeTabs" dolayout="true" minwidth="100" data-dojo-type="dijit/layout/ContentPane" data-dojo-attach-point="scopeTabs" widgetid="dijit_layout_ContentPane_0"></div>
<div id="xwt_widget_objectselector__SelectionDisplayBar_0" class="xwtOsSelectionBar" minwidth="100" data-dojo-attach-point="selectionBar" widgetid="xwt_widget_objectselector__SelectionDisplayBar_0" style="width: 268px;"></div>
</div>
<div id="dijit_layout_StackContainer_0" class="xwtobjectselectorview dijitStackContainer dijitContainer dijitLayoutContainer xwtOSDataReady xwtOsStackContainer" dolayout="true" data-dojo-attach-point="containerNode" widgetid="dijit_layout_StackContainer_0" style="width: 273px; height: 214px;"></div>
</div>
<div class="resizeHandleBoth" data-dojo-attach-point="resizeHandleAP" style="display: none;"></div>
<div class="xwtOsFooter"></div>
<div class="xwtOsLeftShadow"></div>
<div class="xwtOsRightShadow"></div>
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="xwtPopoverFooter" data-dojo-attach-point="footer"></div>
</div>
<!--
Added connector attach point
-->
<div class="dijitTooltipConnector" data-dojo-attach-point="connector" wairole="presentation" style="left: 8px;"></div>
<div class="xwtPopoverLoader icon-spinner icon-spin" data-dojo-attach-point="loader" style="bottom: 139.333px; left: 153.5px; display: none;"></div>
</div>
</div>
Ok, first at all, if you need to set any text to this field, you can make div with:
id => 'pgObjectSelector_Popover' with JavaScript, using execute_script: #browser.execute_script("document.getElementById('pgObjectSelector_Popover').style.display = 'block';"), after, this pop-up have just one text_field so, you can do: #browser.div(pgObjectSelector_Popover).text_field.set 'ethernet'
Second,
#browser.div(:class=>/DownArrowButton/).when_present.click
#browser.div(:id=>'pgObjectSelector_Popover').text_field.set 'ethernet'

Sharepoint. Custom buttons

I have a SharePoint site, I want all the buttons to be in center and visible, but some of them are out of borders, I replaced my file Default.aspx with another from site with buttons(I also copied Image folder and all files I need). But in my site all buttons are placed very left and I want them to be in center.
What can I do?
For example this is code of button with phone on it:
<tr>
<td width="181" height="120" rowspan="1" colspan="1" style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px">
<div class="mosaic-news right">
<div class="mosaic-overlay">
<a href="http://workpoint.company.corp/teams/TEM1/BAT%20IS/Pages/Telephony_rus.aspx" style="display: block">
<img class="teams" src="images/rus/telephony.png" alt=""/>
</div>
<div class="details">
<!-- INNER TEXT -->
<div style="position: absolute; width: 182px; height: 120px">
<p class="sq_section" style="top: 50%;height: 120px; margin-top: 40px;">Fabric phones<br/>and phones</p>
</div>
</a>
<!-- END -->
</div>
</div>
</td>
</tr>
<tr>

Resources