can't click button in bootstrap-dropdown with selenium - selenium

I'm building a python script to automate the process of uploading beats to Beatstars (since they haven't made an api yet) but I'm running into an issue with the bs-dropdowns on Beatstars studio.
All other things work fine using selenium; I can create a new track, upload the wav, mp3, and stems, but I get stuck when trying to upload a picture for the beat because of this dropdown issue. Below I've shown the issue while trying to edit an already existing track but the concept still the same.
Here's what's happening. I open the dropdown by clicking this button here:
<button
ngcontent-uvy-c103=""
bssquarebuttonfocus=""
type="button"
class="action-element primary ng-star-inserted"
>
<i _ngcontent-uvy-c309="" class="icon-ellipsis ng-star-inserted"></i
><!---->
</button>
And here's the dropdown:
<div class="mat-menu-content ng-tns-c89-57">
<studio-option-edit
_ngcontent-uvy-c309=""
_nghost-uvy-c303=""
class="ng-tns-c89-57 ng-star-inserted"
style=""
><bs-external-action-option
_ngcontent-uvy-c303=""
label="Edit"
iconname="edit-o"
_nghost-uvy-c135=""
><button
_ngcontent-uvy-c135=""
mat-menu-item=""
class="mat-focus-indicator option-action-mat-menu mat-menu-item"
role="menuitem"
tabindex="0"
aria-disabled="false"
>
<i _ngcontent-uvy-c135="" class="icon-edit-o ng-star-inserted"></i
><!----><span _ngcontent-uvy-c135="">Edit</span>
<div
matripple=""
class="mat-ripple mat-menu-ripple"
></div></button></bs-external-action-option></studio-option-edit
><studio-option-share-inventory
_ngcontent-uvy-c309=""
_nghost-uvy-c305=""
class="ng-tns-c89-57 ng-star-inserted"
style=""
><bs-external-action-option
_ngcontent-uvy-c305=""
iconname="share-o"
_nghost-uvy-c135=""
><button
_ngcontent-uvy-c135=""
mat-menu-item=""
class="mat-focus-indicator option-action-mat-menu mat-menu-item"
role="menuitem"
tabindex="0"
aria-disabled="false"
>
<i _ngcontent-uvy-c135="" class="icon-share-o ng-star-inserted"></i
><!----><span _ngcontent-uvy-c135="">Share</span>
<div
matripple=""
class="mat-ripple mat-menu-ripple"
></div></button></bs-external-action-option></studio-option-share-inventory
><!----><studio-option-download
_ngcontent-uvy-c309=""
_nghost-uvy-c308=""
class="ng-tns-c89-57 ng-star-inserted"
style=""
><bs-external-action-option
_ngcontent-uvy-c308=""
label="Download"
iconname="download"
_nghost-uvy-c135=""
><button
_ngcontent-uvy-c135=""
mat-menu-item=""
class="mat-focus-indicator option-action-mat-menu mat-menu-item"
role="menuitem"
tabindex="0"
aria-disabled="false"
>
<i _ngcontent-uvy-c135="" class="icon-download ng-star-inserted"></i
><!----><span _ngcontent-uvy-c135="">Download</span>
<div
matripple=""
class="mat-ripple mat-menu-ripple"
></div></button></bs-external-action-option></studio-option-download
><!----><bs-external-action-option
_ngcontent-uvy-c309=""
_nghost-uvy-c135=""
class="ng-tns-c89-57 ng-star-inserted"
style=""
><button
_ngcontent-uvy-c135=""
mat-menu-item=""
class="mat-focus-indicator option-action-mat-menu mat-menu-item"
role="menuitem"
tabindex="0"
aria-disabled="false"
>
<i _ngcontent-uvy-c135="" class="icon-featured ng-star-inserted"></i
><!----><span _ngcontent-uvy-c135="">Feature</span>
<div
matripple=""
class="mat-ripple mat-menu-ripple"
></div></button></bs-external-action-option
><!----><studio-option-delete-inventory
_ngcontent-uvy-c309=""
label="Track"
_nghost-uvy-c292=""
class="ng-tns-c89-57 ng-star-inserted"
style=""
><bs-external-action-option
_ngcontent-uvy-c292=""
label="Delete"
iconname="delete-o"
_nghost-uvy-c135=""
><button
_ngcontent-uvy-c135=""
mat-menu-item=""
class="mat-focus-indicator option-action-mat-menu mat-menu-item"
role="menuitem"
tabindex="0"
aria-disabled="false"
>
<i _ngcontent-uvy-c135="" class="icon-delete-o ng-star-inserted"></i
><!----><span _ngcontent-uvy-c135="">Delete</span>
<div
matripple=""
class="mat-ripple mat-menu-ripple"
></div></button></bs-external-action-option></studio-option-delete-inventory
><!---->
</div>
The specific button I want to click is the first one:
<button
_ngcontent-uvy-c135=""
mat-menu-item=""
class="mat-focus-indicator option-action-mat-menu mat-menu-item"
role="menuitem"
tabindex="0"
aria-disabled="false"
>
<i _ngcontent-uvy-c135="" class="icon-edit-o ng-star-inserted"></i
><!----><span _ngcontent-uvy-c135="">Edit</span>
<div matripple="" class="mat-ripple mat-menu-ripple"></div>
</button>
And, finally, here's my short script:
wait.until(EC.element_to_be_clickable((By.XPATH, '/html/body/studio-root/div/ng-component/studio-tabs/ng-component/studio-page-container/div/studio-inventory-list-holder/studio-container-grid/div[1]/studio-media-card/div/div[4]/studio-button-item-menu/bs-menu-more-options/div/bs-square-button/button'))).click()
wait.until(EC.presence_of_element_located((By.XPATH, '//*[#id="mat-menu-panel-52"]/div/studio-option-edit'))).click()
Since there's no error I'm not sure what I'm doing wrong. I've tried different selectors, but still I get no error and my script keeps running.

Related

selenium : how to click() elements inside div data-marker=""

I have this element where the code of the content is not inside normal html marks but inside a data-marker attribute of div :
<div class="profil-block d-flex firm" data-lat="45.812122" data-lon="3.112388" data-title="AGC CEGESMA" data-marker="<div class="profil-block firm w-auto m-0 p-0 no-box-shadow">
<a href="/expert-comptable/5213-agc-cegesma-clermont-ferrand-63100" class="d-block text-center">
<img class="avatar" src="/build/images/content/cabinet-anonyme.aa87fff0.svg"/>
</a>
<div class="name w-auto mt-2">
<a href="/expert-comptable/5213-agc-cegesma-clermont-ferrand-63100" class="text-decoration-none">AGC CEGESMA</a>
</div>
<span class="address">
<svg class="primary-red-icon mb-1" width="18" height="18">
<use xlink:href="/build/images/design/icon-lieu-sprite.be93487d.svg#icon-lieu"/>
</svg>
Clermont-Ferrand (63100)
</span>
<div class="info d-flex flex-row mt-2 justify-content-between align-items-center">
<div class="d-flex">
<span role="button" class="icon-block mr-2 firm-phone cursor-pointer" data-id="260000451205">
<svg class="icon icon-tel"><use xlink:href="/build/images/design/contact-icons-sprite.7e44022e.svg#icone-tel"></use></svg>
</span>
<span role="button" class="icon-block firm-contact cursor-pointer" data-id="260000451205">
<svg class="icon icon-mail"><use xlink:href="/build/images/design/contact-icons-sprite.7e44022e.svg#icone-mail"></use></svg>
</span>
</div>
<a href="/expert-comptable/5213-agc-cegesma-clermont-ferrand-63100" class="d-flex flex-column text-decoration-none">
<span class="knowMore">En savoir</span>
<img src="/build/images/design/plus.b2364558.svg" class="icon-more">
</a>
</div>
</div>
">
<div class="d-flex align-items-start">
<a href="/expert-comptable/5213-agc-cegesma-clermont-ferrand-63100" title="En savoir plus sur le cabinet AGC CEGESMA">
<img src="/build/images/content/cabinet-anonyme.aa87fff0.svg" class="avatar" alt="AGC CEGESMA – Expert-comptable logo">
</a>
<div class="d-desktop-none">
<h3 class="name">
AGC CEGESMA
</h3>
<span class="address">
<svg class="primary-red-icon mb-1" width="18" height="18">
<title>Adresse</title>
<use xlink:title="" xlink:href="/build/images/design/icon-lieu-sprite.be93487d.svg#icon-lieu"></use>
</svg>
Clermont-Ferrand (63100)
</span>
</div>
</div>
<div class="d-flex flex-column justify-content-between -medium">
<div class="d-desktop-block">
<div class="name">
AGC CEGESMA
</div>
<span class="address">
<svg class="primary-red-icon mb-1" width="18" height="18">
<title>Adresse</title>
<use xlink:href="/build/images/design/icon-lieu-sprite.be93487d.svg#icon-lieu"></use>
</svg>
Clermont-Ferrand (63100)
</span>
</div>
<div class="competence-list">
<div class="competence ">RAY François</div>
</div>
</div>
<div class="info d-flex justify-content-between">
<div class="d-flex">
<div role="button" class="icon-block mr-2 firm-phone cursor-pointer" data-id="260000451205" title="Contacter le cabinet AGC CEGESMA par téléphone">
<svg class="icon icon-tel"><use xlink:href="/build/images/design/contact-icons-sprite.7e44022e.svg#icone-tel"></use></svg>
</div>
<div role="button" class="icon-block firm-contact cursor-pointer" data-id="260000451205" title="Contacter le cabinet AGC CEGESMA par mail">
<svg class="icon icon-mail"><use xlink:href="/build/images/design/contact-icons-sprite.7e44022e.svg#icone-mail"></use></svg>
</div>
</div>
<a href="/expert-comptable/5213-agc-cegesma-clermont-ferrand-63100" class="d-flex flex-column text-decoration-none" title="En savoir plus sur le cabinet AGC CEGESMA">
<span class="knowMore">En savoir</span>
<img src="/build/images/design/plus.b2364558.svg" class="icon-more">
</a>
</div>
</div>
I can retrieve the content with driver.find_elements(by=By.XPATH, value='//div[#class="profil-block d-flex firm"]').get_attribute('data-marker'), but then how to i select some buttons for example inside this attribute?
I need selenium to click a link inside this data-marker code
Thank you
I don't think it is possible to click on an element thats only in the data-marker. In your situation though you can just locate this element:
This code should work for locating that element:
driver.find_elements(by=By.XPATH, value='//div[#class="icon-block firm-contact cursor-pointer"]')

while writing selenium scripting in website and but it will not go sidebar options window through selenium scripts

While writing selenium scripts in a web page and it's working auto login window, but while going sidebar options in website is not working
driver.findElement(By.xpath("//*[#id='mCSB_22_container']/ul/li[8]/i"));
I have used these xpath but not working
<li _ngcontent-c11="" routerlinkactive="active" title="Alert Configuration" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" class="fa fa-exclamation-triangle" style="color:rgb(214, 111, 111);"></i>
</li>
<!----><li _ngcontent-c11="" title="Device Profile">
<i _ngcontent-c11="" aria-hidden="true" class="fa fa-cog" style="color:lightBlue;"></i>
</li>
<!----><li _ngcontent-c11="" title="Poles">
<img _ngcontent-c11="" src="./assets/images/lamp-pole-group-12x12.png"> </li>
<!----><li _ngcontent-c11="" title="Lamps">
<img _ngcontent-c11="" src="./assets/images/pole-lamps-12x12.png" class="mCS_img_loaded"> </li>
<li _ngcontent-c11="" routerlinkactive="active" title="Commissioning Process" tabindex="0" style="display: inherit;">
<img _ngcontent-c11="" src="./assets/images/Commissioning-Process.png" class="mCS_img_loaded">
</li>
<!----><li _ngcontent-c11="" title="Groups" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" class="fa fa-users" style="color:#8edd34;"></i>
</li>
<!----><li _ngcontent-c11="" title="Reports" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" class="fa fa-bar-chart" style="color:#d3d347;"></i>
</li>
<!---->
<li _ngcontent-c11="" routerlinkactive="active" title="Archival" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" class="fa fa-archive"></i>
</li>
</ul>
Dashboard
Device Trends
Alerts – Notifications
<li _ngcontent-c11="" class="li-h" style="display: inherit;">User
Management</li>
<!----><li _ngcontent-c11="" routerlinkactive="active" title="Users" tabindex="0" class="active">
<i _ngcontent-c11="" aria-hidden="true" style="color:#3289c8;">
<div _ngcontent-c11="" class="fa fa-user mlr10 aligncenter"></div>
</i>Users</li>
<li _ngcontent-c11="" class="overflowEllipsel" routerlinkactive="active" title="Roles & Permissions" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" style="color:lightBlue;">
<div _ngcontent-c11="" class="fa fa-check-square-o mlr10 aligncenter"></div>
</i>Roles & Permissions</li>
<li _ngcontent-c11="" class="overflowEllipsel" routerlinkactive="active" title="User Activity Tracking" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true">
<div _ngcontent-c11="" class="fa fa-pencil-square-o mlr10 aligncenter"></div>
</i>User Activity Tracking</li>
<li _ngcontent-c11="" class="li-h" style="display: inherit;">Configuration
Settings</li>
<li _ngcontent-c11="" class="overflowEllipsel" routerlinkactive="active" title="Project Configuration" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" style="color:lightBlue;">
<div _ngcontent-c11="" class="fa fa-handshake-o mlr10 aligncenter"></div>
</i>Project Configuration</li>
<!----><li _ngcontent-c11="" class=" overflowEllipsel" routerlinkactive="active" title="One Step Onboarding" tabindex="0">
<i _ngcontent-c11="" aria-hidden="true" style="color:#fff;">
<div _ngcontent-c11="" class="fa fa-user mlr10 aligncenter"></div>
</i>One Step Onboarding</li>
<li _ngcontent-c11="" class="arrow-toggle collapsed" data-target="#collapseHierarchy" data-toggle="collapse" title="Hierarchy" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true">
<div _ngcontent-c11="" class="fa fa-bar-chart mlr10 aligncenter"></div>
</i>Hierarchy
<span _ngcontent-c11="" class="fr mlr10">
<span _ngcontent-c11="" class="fa fa-plus caret1 plr5"></span>
<span _ngcontent-c11="" class="fa fa-minus caret1 plr5"></span>
</span>
</li>
<ul _ngcontent-c11="" class="collapse " id="collapseHierarchy">
<li _ngcontent-c11="" class="pl1cm overflowEllipsel" routerlinkactive="active" title="Hierarchy Definition" tabindex="0" style="display: inherit;">Hierarchy Definition</li>
<li _ngcontent-c11="" class="pl1cm overflowEllipsel" routerlinkactive="active" title="Hierarchy Creation" tabindex="0" style="display: inherit;">Hierarchy Creation</li>
</ul>
<li _ngcontent-c11="" class=" overflowEllipsel" routerlinkactive="active" title="Alert Configuration" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" style="color:rgb(214, 111, 111);">
<div _ngcontent-c11="" class="fa fa-exclamation-triangle mlr10 aligncenter"></div>
</i>Alert Configuration</li>
<!----><li _ngcontent-c11="" class="arrow-toggle collapsed" data-target="#collapseExample" data-toggle="collapse" title="Device Profiles">
<i _ngcontent-c11="" aria-hidden="true" style="color:lightblue">
<div _ngcontent-c11="" class="fa fa-cog mlr10 aligncenter"></div>
</i>Device Profile
<span _ngcontent-c11="" class="fr mlr10 ">
<span _ngcontent-c11="" class="fa fa-minus caret1 plr5"></span>
<span _ngcontent-c11="" class="fa fa-plus caret1 plr5"></span>
</span>
</li>
<!----><ul _ngcontent-c11="" class="collapse" id="collapseExample">
<li _ngcontent-c11="" class="pl1cm overflowEllipsel" routerlinkactive="active" title="Device Profile Master" tabindex="0">Device Profile Master</li>
<li _ngcontent-c11="" class="pl1cm overflowEllipsel" routerlinkactive="active" title="Profile Settings" tabindex="0">Profile
Settings</li>
</ul>
<!----><li _ngcontent-c11="" class="li-h">Device
Onboarding</li>
<!----><li _ngcontent-c11="" class="arrow-toggle collapsed" data-target="#collapsePoles" data-toggle="collapse" title="Poles">
<img _ngcontent-c11="" class="mlr10" src="./assets/images/lamp-pole-group-12x12.png"> Poles
<span _ngcontent-c11="" class="fr mlr10 w15">
<span _ngcontent-c11="" class="fa fa-minus caret1 plr5"></span>
<span _ngcontent-c11="" class="fa fa-plus caret1 plr5"></span>
</span>
</li>
<!----><ul _ngcontent-c11="" class="collapse" id="collapsePoles">
<!----><li _ngcontent-c11="" class="pl1cm overflowEllipsel pr15" routerlinkactive="active" title="Poles Management" tabindex="0">Poles
Management</li>
<!----><li _ngcontent-c11="" class="pr15 pl1cm overflowEllipsel" routerlinkactive="active" title="Poles Association with Hierarchy" tabindex="0">Poles
Association with Hierarchy</li>
</ul>
<!----><li _ngcontent-c11="" class="arrow-toggle collapsed" data-target="#collapseLamps" data-toggle="collapse" title="Lamps">
<img _ngcontent-c11="" class="mlr10" src="./assets/images/pole-lamps-12x12.png"> Lamps
<span _ngcontent-c11="" class="fr mlr10 w15">
<span _ngcontent-c11="" class="fa fa-minus caret1 plr5"></span>
<span _ngcontent-c11="" class="fa fa-plus caret1 plr5"></span>
</span>
</li>
<!----><ul _ngcontent-c11="" class="collapse" id="collapseLamps">
<!----><li _ngcontent-c11="" class="pl1cm overflowEllipsel pr15" routerlinkactive="active" title="Lamp Management" tabindex="0">Lamp
Management</li>
<!----><li _ngcontent-c11="" class="pl1cm overflowEllipsel pr15" routerlinkactive="active" title="Lamp Association with Poles" tabindex="0">Lamp
Association with Poles</li>
</ul>
<!---->
<!---->
<li _ngcontent-c11="" class="li-h" style="display: inherit;">Group
Actions</li>
<li _ngcontent-c11="" class="arrow-toggle collapsed overflowEllipsel" routerlinkactive="active" title="Commissioning Process" type="button" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" style="color:lightblue">
<div _ngcontent-c11="" class=" mlr10 w15" style="display: inline-block;">
<img _ngcontent-c11="" src="./assets/images/Commissioning-Process.png" class="mCS_img_loaded">
</div>
</i>Commissioning Process
</li>
<!----><li _ngcontent-c11="" class="arrow-toggle collapsed" data-target="#collapseGroup2" data-toggle="collapse" title="TCL-Multicast" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" style="color:#97972d;">
<div _ngcontent-c11="" class="fa fa-rss mlr10 aligncenter"></div>
</i>TCL-Multicast
<span _ngcontent-c11="" class="fr mlr10">
<span _ngcontent-c11="" class="fa fa-minus caret1 plr5"></span>
<span _ngcontent-c11="" class="fa fa-plus caret1 plr5"></span>
</span>
</li>
<ul _ngcontent-c11="" class="collapse " id="collapseGroup2">
<!----><li _ngcontent-c11="" title="Configuration" tabindex="0" style="display: inherit;">Configuration</li>
<!----><li _ngcontent-c11="" routerlinkactive="active" title="Broadcasting" tabindex="0" style="display: inherit;">Broadcasting</li>
</ul>
<!---->
<ul _ngcontent-c11="" class="collapse " id="collapseGroup1">
<!---->
<!---->
</ul>
<!---->
<ul _ngcontent-c11="" class="collapse " id="collapseGroup3">
<!---->
<!---->
</ul>
<li _ngcontent-c11="" class="li-h" style="display: inherit;">Reports</li>
<!----><li _ngcontent-c11="" class="arrow-toggle collapsed" data-target="#collapseReports" data-toggle="collapse" title="Reports" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true" style="color:#d3d347;">
<div _ngcontent-c11="" class="fa fa-bar-chart mlr10 aligncenter"></div>
</i>Custom Reports
<span _ngcontent-c11="" class="fr mlr10">
<span _ngcontent-c11="" class="fa fa-minus caret1 plr5"></span>
<span _ngcontent-c11="" class="fa fa-plus caret1 plr5"></span>
</span>
</li>
<!----><ul _ngcontent-c11="" class="collapse " id="collapseReports">
<!---->
<li _ngcontent-c11="" class="pl1cm overflowEllipsel" routerlinkactive="active" title="Health Report" tabindex="0" style="display: inherit;">
Health Report</li>
<li _ngcontent-c11="" class="pl1cm overflowEllipsel" routerlinkactive="active" title="Reports" tabindex="0" style="display: inherit;">Reports</li>
</ul>
<li _ngcontent-c11="" class=" overflowEllipsel" routerlinkactive="active" title="Email Scheduler" tabindex="0" style="display: inherit;"><i _ngcontent-c11="" aria-hidden="true" style="color:#a2a284;">
<div _ngcontent-c11="" class="fa fa-envelope mlr10 aligncenter"></div>
</i>Email Scheduler</l
<li _ngcontent-c11="" class="li-h" style="display: inherit;">Other</li>
<li _ngcontent-c11="" routerlinkactive="active" title="Archival" tabindex="0" style="display: inherit;">
<i _ngcontent-c11="" aria-hidden="true">
<div _ngcontent-c11="" class="fa fa-archive mlr10 aligncenter"></div>
</i>Archival</li>
</ul>
in this you need to find partial link of element
driver.findElement(By.partialLinkText("design-series")).click();
If above code:-
WebElement hover = driver.findElement(By.xpath("//*[#id=\"menu-item-11496\"]"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", hover);
JavaScriptExecutor is an Interface that helps to execute JavaScript through Selenium Webdriver.In Selenium Webdriver, locators like XPath, CSS, etc. are used to identify and perform operations on a web page.
In case, these locators do not work you can use JavaScriptExecutor. You can use JavaScriptExecutor to perform an desired operation on a web element.
JavaScriptExecutor Methods
1)executeAsyncScript
With Asynchronous script, your page renders more quickly. Instead of forcing users to wait for a script to download before the page renders. This function will execute an asynchronous piece of JavaScript in the context of the currently selected frame or window in Selenium. The JS so executed is single-threaded with a various callback function which runs synchronously.
2)executeScript
This method executes JavaScript in the context of the currently selected frame or window in Selenium. The script used in this method runs in the body of an anonymous function (a function without a name). We can also pass complicated arguments to it.
The script can return values. Data types returned are
-Boolean
-Long
-String
-List
-WebElement
The basic syntax for JavascriptExecutor is given below:
Syntax:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(Script,Arguments);
Script – This is the JavaScript that needs to execute.
Arguments – It is the arguments to the script. It's optional.
need more information then go through this link

Selenium WebDriver could not locate CKEditor iFrame and enter text

Here is html code. I used iFrame class to identify and but unable to locate
<textarea class="form-control qlib-ck-editor" cols="20" id="QuestionText" name="QuestionText" onload="initializeCkInstance('QuestionText');" rows="7" style="visibility: hidden; display: none;"></textarea>
<div id="cke_QuestionText" class="cke_1 cke cke_reset cke_chrome cke_editor_QuestionText cke_ltr cke_browser_webkit" dir="ltr" lang="en" role="application" aria-labelledby="cke_QuestionText_arialbl"><span id="cke_QuestionText_arialbl" class="cke_voice_label">Rich Text Editor, QuestionText</span>
<div class="cke_inner cke_reset" role="presentation"><span id="cke_1_top" class="cke_top cke_reset_all" role="presentation" style="height: auto; user-select: none;">
<span id="cke_14" class="cke_voice_label">Editor toolbars</span>
<span id="cke_1_toolbox" class="cke_toolbox" role="group" aria-labelledby="cke_14" onmousedown="return false;">
<span id="cke_15" class="cke_toolbar cke_toolbar_last" aria-labelledby="cke_15_label" role="toolbar">
<span id="cke_15_label" class="cke_voice_label">Basic Styles</span>
<span class="cke_toolbar_start"></span><span class="cke_toolgroup" role="presentation">
<a id="cke_16" class="cke_button cke_button__bold cke_button_off" href="javascript:void('Bold')" title="Bold (Ctrl+B)" tabindex="-1" hidefocus="true" role="button" aria-labelledby="cke_16_label" aria-describedby="cke_16_description" aria-haspopup="false" onkeydown="return CKEDITOR.tools.callFunction(1,event);" onfocus="return CKEDITOR.tools.callFunction(2,event);" onclick="CKEDITOR.tools.callFunction(3,this);return false;">
<span class="cke_button_icon cke_button__bold_icon" style="background-image:url('https://qlib-qa.azurewebsites.net/Scripts/ckeditor/plugins/icons.png?t=I3I8');background-position:0 0px;background-size:auto;"> </span>
<span id="cke_16_label" class="cke_button_label cke_button__bold_label" aria-hidden="false">Bold</span>
<span id="cke_16_description" class="cke_button_label" aria-hidden="false">Keyboard shortcut Ctrl+B</span>
</a>
<a id="cke_17" class="cke_button cke_button__italic cke_button_off" href="javascript:void('Italic')" title="Italic (Ctrl+I)" tabindex="-1" hidefocus="true" role="button" aria-labelledby="cke_17_label" aria-describedby="cke_17_description" aria-haspopup="false" onkeydown="return CKEDITOR.tools.callFunction(4,event);" onfocus="return CKEDITOR.tools.callFunction(5,event);" onclick="CKEDITOR.tools.callFunction(6,this);return false;">
<span class="cke_button_icon cke_button__italic_icon" style="background-image:url('https://qlib-qa.azurewebsites.net/Scripts/ckeditor/plugins/icons.png?t=I3I8');background-position:0 -24px;background-size:auto;"> </span>
<span id="cke_17_label" class="cke_button_label cke_button__italic_label" aria-hidden="false">Italic</span><span id="cke_17_description" class="cke_button_label" aria-hidden="false">Keyboard shortcut Ctrl+I</span>
</a>
<a id="cke_18" class="cke_button cke_button__underline cke_button_off" href="javascript:void('Underline')" title="Underline (Ctrl+U)" tabindex="-1" hidefocus="true" role="button" aria-labelledby="cke_18_label" aria-describedby="cke_18_description" aria-haspopup="false" onkeydown="return CKEDITOR.tools.callFunction(7,event);" onfocus="return CKEDITOR.tools.callFunction(8,event);" onclick="CKEDITOR.tools.callFunction(9,this);return false;">
<span class="cke_button_icon cke_button__underline_icon" style="background-image:url('https://qlib-qa.azurewebsites.net/Scripts/ckeditor/plugins/icons.png?t=I3I8');background-position:0 -120px;background-size:auto;"> </span>
<span id="cke_18_label" class="cke_button_label cke_button__underline_label" aria-hidden="false">Underline</span>
<span id="cke_18_description" class="cke_button_label" aria-hidden="false">Keyboard shortcut Ctrl+U</span></a>
</span><span class="cke_toolbar_end"></span></span>
</span>
</span>
<div id="cke_1_contents" class="cke_contents cke_reset" role="presentation" style="height: 200px;">
<span id="cke_22" class="cke_voice_label">Press ALT 0 for help</span>
<iframe src="" frameborder="0" class="cke_wysiwyg_frame cke_reset" style="width: 100%; height: 100%;" title="Rich Text Editor, QuestionText" aria-describedby="cke_22" tabindex="0" allowtransparency="true"></iframe>
</div>
<span id="cke_1_bottom" class="cke_bottom cke_reset_all" role="presentation" style="user-select: none;">
<span id="cke_1_resizer" class="cke_resizer cke_resizer_vertical cke_resizer_ltr" title="Resize" onmousedown="CKEDITOR.tools.callFunction(0, event)">◢</span>
<div class="cke_wordcount" style="" title="Statistics">
<span id="cke_wordcount_QuestionText" class="cke_path_item">Characters: 0</span>
</div>
</span>
</div>
</div>

How to locate the dynamic web elements using webdriver

The Web page is written using aspx pages. Where are there are no fixed rows and elements. Which gets changed dynamically.
Please review the attached code and let me know how to form CSS Selector path/Xpath to locate the button "showAirlineCreateButton", whose position changes dynamically.
<div class="row">
<div class="client_name col-xs-offset-2 col-xs-8">
<h4 class="ng-binding">TEST </h4>
</div>
<!-- ngRepeat: scheduleBasicDetail in Airline_item.scheduleBasicDetailList --><div ng-repeat="scheduleBasicDetail in Airline_item.scheduleBasicDetailList" class="ng-scope">
<div class="col-xs-offset-2 col-xs-8" style="height:86px;">
<!-- ngIf: scheduleBasicDetail.Client_ID!=0 --><div class="tri_widget widget md-whiteframe-z2 ng-scope ng-isolate-scope flex layout-column" ng-class="::{'widget-overlay-title': vm.overlayTitle}" flex="" layout="column" ng-if="scheduleBasicDetail.Client_ID!=0" title-position="top" ng-click="redirect(scheduleBasicDetail.Schedule_ID,scheduleBasicDetail.Client_ID)" title="" role="button" tabindex="0"><!-- ngIf: ::(vm.title || vm.subtitle) --><div class="widget-content layout-column layout-align-start-stretch flex-order-2" layout="column" layout-align="" ng-class="{'layout-padding': vm.contentPadding}" ng-transclude="" flex-order="2">
<div layout="row" layout-wrap="" class="layout-wrap ng-scope layout-row">
<div flex="10" class="flex-10">
<img class="TESTListFirstTableTdImage" ng-src="http://10.255.109.100/TESTService/Services/../Repository/TEST/TEST/Logo.png" src="http://10.255.109.100/TESTService/Services/../Repository/TEST/TEST/Logo.png">
</div>
<div flex="80" class="Small_Padding_Left flex-80">
<div layout="row" class="layout-row">
<div flex="33" id="title" class="ng-binding flex-33">HX-JAN17-01</div>
<div flex="33" class="AirLineScheduleSystemName ng-binding flex-33">PAC eFX / PAC eX2 / Thales i5000</div>
<div flex="33" class="flex-33"></div>
</div>
<div layout="row" class="layout-row">
<div flex="33" class="flex-33"><span class="TESTScheduleMonth ng-binding">January</span> <br>
<span class="TESTScheduleYear ng-binding">2017</span>
</div>
<div flex="66" class="flex-66"><span class="AirLineScheduleAssets ng-binding">0 Assets</span><br>
<span class="TESTScheduleAssets ng-binding">MOVIES / I-MOVIES / TV / OTHERS</span>
</div>
</div>
</div>
<div flex="10" class="flex-10">
<img ng-src="http://10.255.109.100/TESTService/Services/../Repository/ScheduleStatus/Locked.png" ng-altsrc="../../Images/Common/NoImage.png" onerror="this.src = $(this).attr('altSrc')" src="http://10.255.109.100/TESTService/Services/../Repository/ScheduleStatus/Locked.png">
</div>
</div>
</div><div class="widget-loading ng-hide layout-fill layout-align-center-center layout-row" ng-show="vm.loading" layout="" layout-fill="" layout-align="center center" aria-hidden="true"><div class="widget-loading-inner ng-hide" ng-show="vm.loading" aria-hidden="true"><md-progress-circular md-mode="indeterminate" aria-valuemin="0" aria-valuemax="100" role="progressbar" class="ng-isolate-scope" style="width: 50px; height: 50px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" style="width: 50px; height: 50px;"><path fill="none" transform="rotate(49.63717240968655 25, 25)" d="M23.589212129501437,47.455727055351694A22.5,22.5 0 0,0 28.277287287607944,47.2600401624634" style="stroke-width: 5px;"></path></svg></md-progress-circular></div></div></div><!-- end ngIf: scheduleBasicDetail.Client_ID!=0 -->
<!-- ngIf: scheduleBasicDetail.Client_ID==0 -->
</div>
<div class="col-xs-2 dropdown-parent-div">
<div class="dropdown">
<i class="dropbtn fa fa-bars" aria-hidden="true"></i>
<div class="dropdown-content" style="margin-top:22px">
<strong> <i class="fa fa-file-excel-o icon-4x dropdown-excel-button" aria-hidden="true"> </i></strong>
</div>
<div class="dropdown-content" style="margin-top:22px">
<strong> <i class="fa fa-file-excel-o icon-4x dropdown-excel-button" aria-hidden="true"> </i></strong>
</div>
</div>
</div>
</div><!-- end ngRepeat: scheduleBasicDetail in TEST_item.scheduleBasicDetailList --><div ng-repeat="scheduleBasicDetail in TEST_item.scheduleBasicDetailList" class="ng-scope">
<div class="col-xs-offset-2 col-xs-8" style="height:86px;">
<!-- ngIf: scheduleBasicDetail.Client_ID!=0 --><div class="tri_widget widget md-whiteframe-z2 ng-scope ng-isolate-scope flex layout-column" ng-class="::{'widget-overlay-title': vm.overlayTitle}" flex="" layout="column" ng-if="scheduleBasicDetail.Client_ID!=0" title-position="top" ng-click="redirect(scheduleBasicDetail.Schedule_ID,scheduleBasicDetail.Client_ID)" title="" role="button" tabindex="0"><!-- ngIf: ::(vm.title || vm.subtitle) --><div class="widget-content layout-column layout-align-start-stretch flex-order-2" layout="column" layout-align="" ng-class="{'layout-padding': vm.contentPadding}" ng-transclude="" flex-order="2">
<div layout="row" layout-wrap="" class="layout-wrap ng-scope layout-row">
<div flex="10" class="flex-10">
<img class="AirlineScheduleListFirstTableTdImage" ng-src="http://10.255.109.100/TESTService/Services/../Repository/Airline/TEST/Logo.png" src="http://10.255.109.100/TESTService/Services/../Repository/Airline/TEST/Logo.png">
</div>
<div flex="80" class="Small_Padding_Left flex-80">
<div layout="row" class="layout-row">
<div flex="33" id="title" class="ng-binding flex-33">HX-DEC16-01</div>
<div flex="33" class="AirLineScheduleSystemName ng-binding flex-33">PAC eFX / PAC eX2 / Thales i5000</div>
<div flex="33" class="flex-33"></div>
</div>
<div layout="row" class="layout-row">
<div flex="33" class="flex-33"><span class="TESTScheduleMonth ng-binding">December</span> <br>
<span class="AirLineScheduleYear ng-binding">2016</span>
</div>
<div flex="66" class="flex-66"><span class="AirLineScheduleAssets ng-binding">29 Assets</span><br>
<span class="TESTScheduleAssets ng-binding">MOVIES / I-MOVIES / TV / OTHERS</span>
</div>
</div>
</div>
<div flex="10" class="flex-10">
<img ng-src="http://10.255.109.100/DASHService/Services/../Repository/ScheduleStatus/Locked.png" ng-altsrc="../../Images/Common/NoImage.png" onerror="this.src = $(this).attr('altSrc')" src="http://10.255.109.100/DASHService/Services/../Repository/ScheduleStatus/Locked.png">
</div>
</div>
</div><div class="widget-loading ng-hide layout-fill layout-align-center-center layout-row" ng-show="vm.loading" layout="" layout-fill="" layout-align="center center" aria-hidden="true"><div class="widget-loading-inner ng-hide" ng-show="vm.loading" aria-hidden="true"><md-progress-circular md-mode="indeterminate" aria-valuemin="0" aria-valuemax="100" role="progressbar" class="ng-isolate-scope" style="width: 50px; height: 50px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" style="width: 50px; height: 50px;"><path fill="none" transform="rotate(49.63717240968655 25, 25)" d="M23.589212129501437,47.455727055351694A22.5,22.5 0 0,0 28.276617692292554,47.26013873493504" style="stroke-width: 5px;"></path></svg></md-progress-circular></div></div></div><!-- end ngIf: scheduleBasicDetail.Client_ID!=0 -->
<!-- ngIf: scheduleBasicDetail.Client_ID==0 -->
</div>
<div class="col-xs-2 dropdown-parent-div">
<div class="dropdown">
<i class="dropbtn fa fa-bars" aria-hidden="true"></i>
<div class="dropdown-content" style="margin-top:22px">
<strong> <i class="fa fa-file-excel-o icon-4x dropdown-excel-button" aria-hidden="true"> </i></strong>
</div>
<div class="dropdown-content" style="margin-top:22px">
<strong> <i class="fa fa-file-excel-o icon-4x dropdown-excel-button" aria-hidden="true"> </i></strong>
</div>
</div>
</div>
</div><!-- end ngRepeat: scheduleBasicDetail in Airline_item.scheduleBasicDetailList --><div ng-repeat="scheduleBasicDetail in Airline_item.scheduleBasicDetailList" class="ng-scope">
<div class="col-xs-offset-2 col-xs-8" style="height:86px;">
<!-- ngIf: scheduleBasicDetail.Client_ID!=0 --><div class="tri_widget widget md-whiteframe-z2 ng-scope ng-isolate-scope flex layout-column" ng-class="::{'widget-overlay-title': vm.overlayTitle}" flex="" layout="column" ng-if="scheduleBasicDetail.Client_ID!=0" title-position="top" ng-click="redirect(scheduleBasicDetail.Schedule_ID,scheduleBasicDetail.Client_ID)" title="" role="button" tabindex="0"><!-- ngIf: ::(vm.title || vm.subtitle) --><div class="widget-content layout-column layout-align-start-stretch flex-order-2" layout="column" layout-align="" ng-class="{'layout-padding': vm.contentPadding}" ng-transclude="" flex-order="2">
<div layout="row" layout-wrap="" class="layout-wrap ng-scope layout-row">
<div flex="10" class="flex-10">
<img class="AirlineScheduleListFirstTableTdImage" ng-src="http://10.255.109.100/DASHService/Services/../Repository/Airline/Hong_Kong_Airlines/Logo.png" src="http://10.255.109.100/DASHService/Services/../Repository/Airline/Hong_Kong_Airlines/Logo.png">
</div>
<div flex="80" class="Small_Padding_Left flex-80">
<div layout="row" class="layout-row">
<div flex="33" id="title" class="ng-binding flex-33">HX-SEP16-01</div>
<div flex="33" class="AirLineScheduleSystemName ng-binding flex-33">PAC eFX / PAC eX2 / Thales i5000</div>
<div flex="33" class="flex-33"></div>
</div>
<div layout="row" class="layout-row">
<div flex="33" class="flex-33"><span class="AirLineScheduleMonth ng-binding">September</span> <br>
<span class="AirLineScheduleYear ng-binding">2016</span>
</div>
<div flex="66" class="flex-66"><span class="AirLineScheduleAssets ng-binding">50 Assets</span><br>
<span class="AirLineScheduleAssets ng-binding">MOVIES / I-MOVIES / TV / OTHERS</span>
</div>
</div>
</div>
<div flex="10" class="flex-10">
<img ng-src="http://10.255.109.100/DASHService/Services/../Repository/ScheduleStatus/Locked.png" ng-altsrc="../../Images/Common/NoImage.png" onerror="this.src = $(this).attr('altSrc')" src="http://10.255.109.100/DASHService/Services/../Repository/ScheduleStatus/Locked.png">
</div>
</div>
</div><div class="widget-loading ng-hide layout-fill layout-align-center-center layout-row" ng-show="vm.loading" layout="" layout-fill="" layout-align="center center" aria-hidden="true"><div class="widget-loading-inner ng-hide" ng-show="vm.loading" aria-hidden="true"><md-progress-circular md-mode="indeterminate" aria-valuemin="0" aria-valuemax="100" role="progressbar" class="ng-isolate-scope" style="width: 50px; height: 50px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" style="width: 50px; height: 50px;"><path fill="none" transform="rotate(49.63717240968655 25, 25)" d="M23.589212129501437,47.455727055351694A22.5,22.5 0 0,0 28.275447404006268,47.260310966012774" style="stroke-width: 5px;"></path></svg></md-progress-circular></div></div></div><!-- end ngIf: scheduleBasicDetail.Client_ID!=0 -->
<!-- ngIf: scheduleBasicDetail.Client_ID==0 -->
</div>
<div class="col-xs-2 dropdown-parent-div">
<div class="dropdown">
<i class="dropbtn fa fa-bars" aria-hidden="true"></i>
<div class="dropdown-content" style="margin-top:22px">
<strong> <i class="fa fa-file-excel-o icon-4x dropdown-excel-button" aria-hidden="true"> </i></strong>
</div>
<div class="dropdown-content" style="margin-top:22px">
<strong> <i class="fa fa-file-excel-o icon-4x dropdown-excel-button" aria-hidden="true"> </i></strong>
</div>
</div>
</div>
</div><!-- end ngRepeat: scheduleBasicDetail in Airline_item.scheduleBasicDetailList -->
<div class="col-xs-8 col-xs-offset-2 div_add_btn">
<!-- ngIf: showAirlineCreateButton --><div class="col-xs-6 col-xs-offset-6 text-center add_btn_schedule ng-scope" ng-click="Show_AirName(Airline_item.Client_ID,Airline_item.ClientName,Airline_item.scheduleBasicDetailList[0].Schedule_ID)" data-toggle="modal" data-target="#myModal" data-ng-if="showAirlineCreateButton" role="button" tabindex="0">
<span class="fa fa-plus" aria-label="Create a Schedule">
</span>
/div><!-- end ngIf: showAirlineCreateButton -->
</div>
</div>
You can use this XPath that should work no matter where element located:
//div[#data-ng-if="showAirlineCreateButton"]

How can I Selecting Kendo Drop Down using xpath

I have the following HTML:
<table class="w98">
<tbody>
<tr>
<tr>
<tr>
<td class="p-controlSetLabel">
<td class="editor-field">
**<span class="k-widget k-dropdown k-header" style="width: 165px;" title="" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="VatRateId_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="304dd433-4a68-458b-a6d6-03b72335f1cb">**
<span class="k-dropdown-wrap k-state-default" unselectable="on">
<span class="k-input" unselectable="on">Standard - Standard</span>
<span class="k-select" unselectable="on">
<span class="k-icon k-i-arrow-s" unselectable="on">select</span>
</span>
</span>
<input id="VatRateId" class="k-valid" type="text" value="d20b" style="width: 165px; display: none;" name="VatRateId" data-val-required="Please select a VAT Rate." data-val="true" data-role="dropdownlist">
The input id="VatRateId" is hidden, so I can't access it.
My current solution is the following:
var allDropDownFields = FindElements(By.XPath(".//*[#class='k-dropdown-wrap k-state-default']") -- This will return a list of all drop down fields
Then I loop each one of them to find the correct drop down field I want.
Is there a better way of finding the element without getting a list, I tried the following:
FindElement(By.XPath(".//*[#class='k-dropdown-wrap k-state-default'and #aria-owns = 'VatRateId_listbox']")
and the above code is not work.
HTML code is as below:-
<span class="k-widget k-dropdown k-header" style="width: 165px;" title="" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="VatRateId_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="304dd433-4a68-458b-a6d6-03b72335f1cb">* <span class="k-dropdown-wrap k-state-default" unselectable="on"> <span class="k-input" unselectable="on">Standard - Standard</span>
Any better suggestion?