Home > Blockchain >  How to access element within a signOn window within a PowerBI page with selenium vba
How to access element within a signOn window within a PowerBI page with selenium vba

Time:02-02

When I try to target the email element by class or id, it will throw an error:

run-time error '438': object doesn't support this property or method

There are no iframes and I can't seem to switch to a window either(that I am seeing).

Here is vba code:

Set bot = New Selenium.ChromeDriver
   bot.start baseUrl:="https://app.powerbi.com/singleSignOn"
   bot.Get "/"
   Application.Wait Now   TimeValue("00:00:3")
   Dim FindBy As New Selenium.By

   With bot
    .FindElementsByCss(".pbi-text-input").Click
    .FindElementsById("email").SendKeys ("testing")
   end with

Html code:

    </head>
    <body>
        <div id="emailCollection"  style="display: none;"> <!-- The popup window -->
            <div >                
                <object type="image/svg xml" data="13.0.17576.29/images/PowerBI_MasterLogo.svg"></object>
                <label>Power BI</label>
            </div>
            <div >
                <div ><label>Enter your email, we&#39;ll check if you need to create a new account.</label></div>
                <div >
                    <div >
                        <div >
                            <div >Email</div>
                            <div><input  type="text" placeholder="Enter email" id="email"></div>
                            <div  style="display: none;"></div>
                        </div>
                        <div >
                            <div >
                                By proceeding you acknowledge that if you use your organization&#39;s email, your organization may have rights to access and manage your data and account.
                                <span  onm ouseover="setPosition(event)">
                                    Learn more about using your organization&#39;s email
                                    <span >
                                        <b>Using your organization&#39;s email address to sign up</b>
                                        <p>If you use an email address provided by an organization you are affiliated with (like an employer or school), the owner of the email domain may (i) manage and administer your account, including modifying and terminating your access and (ii) access and process your data, including the contents of your communications and files. Your directory data (including name, signup date, and email) may be visible to other users of these services within your organization.
                                        </p>
                                    </span>
                                </span>
                            </div>
                            
                            <div >
                                By clicking Submit, you agree to these <a href='https://go.microsoft.com/fwlink/?LinkID=870457&clcid=0x409' target='_blank'>terms and conditions</a> and allow Power BI to get your user and tenant details. <a href='https://go.microsoft.com/fwlink/?LinkID=521839&clcid=0x409' target='_blank'>Microsoft Privacy Statement</a>
                            </div>
                        </div>
                    </div>
                    <button  id="submitBtn" onclick="submitEmail()">Submit</button>
                </div>
            </div>
            <div >
                <object type="image/svg xml" data="13.0.17576.29/images/PowerBI_MasterLogo.svg"></object>
            </div>
        </div>
    </body>
</html>

url: https://app.powerbi.com/singleSignOn

CodePudding user response:

As the website is Power BI enabled, 3 seconds may not be enough for the element to be clickable.

You may increase the wait time to 10 secs and you can use either of the following Locator Strategies:

  • Using FindElementByCss:

    bot.FindElementByCss("input.pbi-text-input#email[placeholder='Enter email'][type='text']").SendKeys ("Red")
    
  • Using FindElementByXPath:

    bot.FindElementByXPath("//input[@class='pbi-text-input' and @id='email'][@placeholder='Enter email' and @type='text']").SendKeys ("Red")
    
  •  Tags:  
  • Related