FIND ELEMENT BY XPATH WITH SELENIUM WEBDRIVER USING PYTHON : I want to upload the file on onedrive with python.
But i am unable to locate Upload button. Element found with xpath in driver but while writing in code it throws timeout exception.
HTML CODE:
<div class="CommandBarItem beak-anchor command is-focused" data-bind="css: { 'is-toggled': isOpen() || isToggled(), 'is-disabled': isDisabled, 'is-disabled-invisible': isInvisibleWhenDisabled, 'is-open': isOpen, 'is-focused': focused, 'CommandBarItem--hasPayload': $component.hasPayload, 'icon-only': hasIconOnly, 'is-current-view': isCurrentView, 'is-pivot': isCurrentView !== null, 'is-last-pivot': isLastPivot }, class: commandClass() ? 'od-Command--' + commandClass() : '', hasFocus: isActive, raiseEventOnChange: { eventName: 'layoutChange', bubbleEvent: true, data: layoutChanged }, dismiss: { isOpen: isOpen, isAutomatic: payload &amp;&amp; payload.autoDismiss, timeout: payload &amp;&amp; payload.timeout, dismissOnResize: false, dismissOnScroll: false }, with: targetCommand(), attr: { tabindex: tabindex, role: role, 'aria-label': $parent.accessibleLabel, 'aria-haspopup': visibleChildren().length > 0 || !!payload, 'aria-selected': isOpen(), 'aria-pressed': isToggled(), 'data-automationid': automationId, 'aria-expanded': visibleChildren().length > 0 ? isOpen().toString() : false, id: newFeatureExperienceAnchor }, teachingBubble: teachingBubble, tooltip: { content: $data.tooltip, isTooltipDisabled: isOpen }" tabindex="0" role="menuitem" aria-label="Upload. Upload files from your computer to this location" aria-haspopup="true" data-automationid="" aria-expanded="false"><div class="CommandBarItem-linkWrapper"><div class="CommandBarItem-link" data-bind="measure: { measure: $parent.measurementReady, async: true }, click: onClick, automation: 'link'" data-automationid="link"><!--ko if: $parent.icon--><span class="CommandBarItem-icon" data-bind="component: { name: 'od-icon-glyph', params: { icon: $parent.icon, badge: $parent.iconBadge } }, attr: { 'is-flipped': $parent.positionIconRight }"><i class="od-IconGlyph ms-Icon ms-Icon--Upload css-46 od-IconGlyph--visible" data-bind="class: iconClasses, attr: { 'data-icon-name': icon }, css: { 'od-IconGlyph--badged': badge, 'od-IconGlyph--visible': icon }, with: badge" data-icon-name="Upload"></i></span><!--/ko--><!--ko if: $parent.iconUrl--><!--/ko--><!--ko if: $parent.label()--><span class="CommandBarItem-commandText" data-bind="text: $parent.label, attr: { 'is-flipped': $parent.positionIconRight, 'role': $parent.hasDynamicText ? 'status' : null, 'aria-live': $parent.hasDynamicText ? 'polite' : null }, css: { 'CommandBarItem-commandText--isStrong': $parent.isStrong, 'ms-accessible': $parent.hasIconOnly() || !$parent.isLabelVisible() }">Upload</span><!--/ko--><!--ko if: visibleChildren().length && !hidesMenuChevron && !isCollapsed() && $parent.isLabelVisible()--><i class="od-CommandBarItem-down ms-Icon css-47" data-bind="class: getChevronDown()"></i><!--/ko--></div><!--ko if: $data.inputType() === ActionInputType.htmlFileUpload--><!--/ko--><!--ko if: $data.inputType() === ActionInputType.folderUpload--><!--/ko--></div><!--ko if: children().length && isOpen() && !isClipped()--><!--/ko--><!--ko if: $component.hasPayload--><!--/ko--></div>


My code:

driver.implicitly_wait(30)
try:
 df = wait.until ( EC.presence_of_element_located ( (By.XPATH, '//*[@id="appRoot"]//div[@class="CommandBarItem beak-anchor command is-focused" and @aria-label="Upload. Upload files from your computer to this location"]')))
 df.click ()
 print (df)
except TimeoutException:
    print ( "page time to load" )

But it does not work and throws the time out exception