简体   繁体   中英

Unable to click on Dynamics365 drop down menu using Selenium/c# - “ElementNotVisibleException”

I'm automating Dynamics365 CRM using Selenium/C#. Able to click and drop the menu, but unable to find and click on the "Submitted" option (line 2 code). Getting this exception: OpenQA.Selenium.ElementNotVisibleException: '// [contains(text(),'Submitted')]'*. Appreciate any ideas how to handle this issue. Also I've given the gui and html below. Highlighted in last picture is the field where drop down is.

使用的功能 在此处输入图像描述 在此处输入图像描述

Automating/scraping Dynamics 365 on the WEB UI side can be difficult, I have been there. The UI form uses a lot of JS event handling, css class naming to show/hide values, boxes etc.. By relying on just calling "click" event on elements, i'm sure will be difficult if not impossible for you to reach your goals. For instance, the elements are sometimes sensitive to mouse hover and click events, at the same time? Are you able to interface with local js objects?. Because there is a way easier way. Dynamics 365 uses a local js Form API called Xrm so google that: Here is an example of getting list of attributes available on the form. Run this in browser console.

Xrm.Page.getAttribute()

It will return a list of attribute names. Find the attribute name that corresponds to you dropdown field. To get a list of available option values (key/value pair) you can simple do:

Xrm.Page.getAttribute("industrycode").getOptions()
// industrycode in this example is a standard attribute of account entity
// returns [{ name: <string>, value: <int>  }, {...} ]

Find the correct value and set the field like so:

Xrm.Page.getAttribute("industrycode").setValue([value])

Then save the form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM