Reputation: 255
when i open with inspect element i see code like this:
<div spellcheck="false" unselectable="off" class="appmagic-label-text" data-control-part="text" data-bind="{
inlineEditText: properties.Text,
css: {
'appmagic-label-single-line': !properties.Wrap()
},
attr: {
'aria-live': live,
'aria-atomic': live() ? 'true' : null
}
}">Atostogų prašymai</div>
and i'm trying to get this text "atostogų prašymai" xpath and there is no way I can find it.
options i have tryied:
By.cssSelector("div[class='appmagic-label-text']");
By.cssSelector("div[class='//*[@id=\"publishedCanvas\"]/div/div[2]/div/div/div[5]/div/div/div/div/div']");
iframe code is visible:
<iframe class="publishedAppIframe" tabindex="0" aria-hidden="false" id="fullscreen-app-host" scrolling="no" frameborder="0" name="fullscreen-app-host" src="https://pa-content.azureedge.net/resource/webplayerdynamic/publishedapp/preloadindex?preloadIndexPath=https%3A%2F%2Fcontent.powerapps.com%2Fresource%2Fapp%2Fupuvepsd66qk3%2Fpreloadindex.web.html&PowerAppsLanguage=en-US&loader=inline&lv=jpigefv5ue8uc&serviceWorkerUrl=https%3A%2F%2Fpa-content.azureedge.net%2Fresource%2Fwebplayer%2Fhashedresources%2Fqqhtjvhh4omr6%2Fjs%2FPowerAppsServiceWorker.PublishedApp.js&piv=796D32DE&featureGates={"publishedAppServiceWorker":false}#%7B%22platform%22%3A%22notwindows%22%2C%22hideNavBar%22%3A%22true%22%2C%22antiCSRFToken%22%3A%22f01dae6c-0d74-4f48-8a74-95b9ee3d5943%22%2C%22cdnUrl%22%3A%22https%3A%2F%2Fcontent.powerapps.com%2Fresource%2Fapp%22%2C%22paramsQuery%22%3A%22tenantId%3Dde6e25a9-36c4-424d-af6b-431db29f6cfe%26appId%3D%2Fproviders%2FMicrosoft.PowerApps%2Fapps%2Fff261fd6-5458-4a3f-8697-f50ff8a1ff06%22%2C%22iframeMode%22%3Anull%2C%22packagePropertiesVersion%22%3A%222.1%22%2C%22staticContentProxy%22%3A%22https%3A%2F%2Fcontent.powerapps.com%2Fresource%2Fwebplayerdynamic%2Fproxy%2Fstaticcontent%3FstaticContentPath%3D%22%2C%22launchFunctionUrlFormat%22%3A%22https%3A%2F%2Fapps.powerapps.com%2Fplay%2F%7B0%7D%22%2C%22region%22%3A%22prod%22%2C%22staticContentUrl%22%3A%22https%3A%2F%2Fstatic.powerapps.com%22%7D" allow="geolocation; microphone; camera; fullscreen" style="" title="Atostogos"></iframe>
and there is methods related with iframe i think:
public void selectIframe() {
String parent = driver.getWindowHandle();
for (String childHandle : driver.getWindowHandles()) {
if (!childHandle.equals(parent)) {
driver.switchTo().frame(childHandle);
}
}
}
public void selectParentFrame() {
driver.switchTo().parentFrame();
}
how can i use them in this situation?
Upvotes: 0
Views: 337
Reputation: 1026
use the xpath as below
//div[@class='appmagic-label-text'][contains(.,'Atostogų prašymai')]
Always build your own xpath. To explain here // stands for relative path, div is the tag, [ stands condition start,@class=''appmagic-label-text' is the query, ] condition end,again here I used another condition as or .[ condition starts , Contains query for finding anything that contains, . stand for anything, matches 'Atostogų prašymai'.
Please note I did not use text so that it will find anything that matches 'Atostogų prašymai' and starts with div tag which has a class appmagic-label-text.
There are many xpath build also available. you may use that. but its always better to build your own xpath
Upvotes: 1
Reputation: 33384
I think you have messed up with css selector and xpath.
your xpath should be
By.Xpath("//div[@class='appmagic-label-text']")
Or more generic
By.Xpath("//div[@class='appmagic-label-text'][text()='Atostogų prašymai']")
Or
By.cssSelector("div.appmagic-label-text")
Update: Since element inside iframe you need to switch it.
new WebDriverWait(driver,10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("fullscreen-app-host")));
WebElement element=new WebDriverWait(driver,10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='appmagic-label-text']")));
To jump out from iframe you need to use
driver.switchTo().defaultContent();
Upvotes: 2