<span class="left-menu-title selectorgadget_selected" data-xpal="xpath-verify-selected" style="">Admin</span>
How can I write an XPath or CSS expression? I tried the plug-ins does not work.
If anyone knows how to click an item from the left-side bar after log-in to the site will be a great help. it does not click, the script fails.
#FindBy(xpath = "//SPAN[#class='left-menu-title'][text()='Admin']")
WebElement clickOnAdmin;
public WebElement adminClick() {
return clickOnAdmin;
}
There are multiple classes but you are checking left-menu-title only.
The case of a SPAN tag name may also be a problem depending on a driver.
Fixed version, using contains() (note that it is not an ideal class XPath check - you need the concat and normalize-space, strictly speaking):
//span[contains(#class, 'left-menu-title')][text()='Admin']
what #alecxe wrote is a very good pointer.
Usually when a website has a strong front-end code embedded with data+JS, you should use functionalities. Especially when absolute xpath does not work such as your case with data var on the front-end. "data-xpal="xpath-verify-selected"
Guru99 xpath fonctionalities
also please verify if your application or website is not embedded with iFrames.
if so please change iframe window.
if you can provide the stackTrace Error. I assume you are talking about NullPointerException or NotFindElementException.
As per the HTML you have shared, the following code block must work :
#FindBy(xpath = "//span[#class='left-menu-title selectorgadget_selected' and contains(.,'Admin')]")
WebElement clickOnAdmin;
public WebElement adminClick() {
clickOnAdmin.click();
}
Note : As you named the function as adminClick(), assuming you want to invoke click() method on the WebElement clickOnAdmin, click() method won't return anything. hence you have to discard the return clickOnAdmin; statement as well.
I would suggest trying writing your XPATH as //span[contains(#class,'left-menu-title') and .='Admin']
And instead of just element.click(); use javascript executor click. Like how it's below:
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", driver.findElement(By.xpath("//span[contains(#class,'left-menu-title') and .='Admin']")));
Hope this works for you! Let me know.
Related
New to coding, trying to see what/if Tags would make this code work
So I'm a beginner with basic understanding and more of a Graphics/ Designer than code based. I found a codepen by WEDOO that has exactly what I need and want to try to just swap my "animationData" to see if I can get it to work and then modify it as needed for my test (will be assign the button code to various objects for the SVG). I Can't seem to find the right "Tags" or determine if its referencing an external script...I'd image it just needs the right information to function...is that correct?
Thanks in advance!
var animation = bodymovin.loadAnimation({
container: targetAnim,
path: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/914929/data-testo4.json...
My output from BodyMovin in a JSON file:
var animationData =
{"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
Does it make sense to think that I need replace the var animation with info that should be the targetAnim with the code in the JSON file? So far put the var animationData breaks things and does nothing (visually).
The bodymovin.loadAnimation can be passed either a URL to a Bodymovin JSON via the path option OR you can pass the animation JSON inline by setting the animationData option instead.
In you case it would end up looking something like:
var animation = bodymovin.loadAnimation({
container: targetAnim,
animationData = {"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
...
})
Tokenize2 is a javacsript lib to select multiple options.
It provides a very neat UI to start writing and then get a list of options to select from. Selected options will show up as "tags" that can be removed with "x" link.
So far all is fine. But Right now you need to know what your looking for and start write at least one character to see matching alternatives.
In my scenario there are very few alternatives and they are not known to the user. I would like to show ALL options when the user clicks the input box. There is a configuration option named searchMinLength but it is already set to 0.
Is there a workaround that can be used? Maybe like triggering load and dropdown manually?
I know there are a lot of similar alternatives but I picked Tokenize2 because:
It looks clean and nice
It works in mobile browsers
I don't know if there is an "official" approach, but after some investigation I have found an acceptable workaround.
After downloading the Tokenizer2 sourceode I found the following line that triggered my attention:
if(this.input.val().length > 0){
this.trigger('tokenize:search', [this.input.val()]);
}
My interpretation is that the internal search command is not triggered unless the user input has at least one character. This line in sourcecode could easily be modified. I have filed a suggestion for this here: https://github.com/zellerda/Tokenize2/issues/26
My current workaround is to add an event listener for the select event and there trigger the internal search command. That works fine for my scenario and does not force a source code rewrite.
$("#my-dropdown").on("tokenize:select", function (e: Event, routedEvent: boolean) {
$("#my-dropdown").trigger('tokenize:search', "");
});
Tokenize2
This link worked for me GitHub
$('.tokenize-sample-demo1').on('tokenize:select', function(container){
$(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
});
I want to change the title of the page after any route has been rendered, to the name of that route. This is the code I was using before:
Router.after(function(){document.title = this.route.name;});
The manual mentions using onAfterAction inside an individual route, but I'd like to do it globally?
You must have missed this : http://eventedmind.github.io/iron-router/#using-hooks
The correct syntax is straightforward :
Router.onAfterAction(function(){
// your hook definition
});
Note : The guide is for iron:router#1.0.0-pre2 which must be added to your app explicitly like this :
meteor add iron:router#1.0.0-pre2
But the Router.onAfterAction works fine in iron:router#0.9.X too.
I suggest using this.route.getName() instead of this.route.name, see more about this issue here :
https://github.com/EventedMind/iron-router/issues/878
The router.after(); method although has been deprecated will still be allowed in the code in terms of syntax. As discussed in the IRC chat the best approach is to use the new syntax.
Router.onAfterAction(function(){
document.title = this.route.name;
});
This should resolve what you are looking for.
Cheers !
Ryan
I have almost 0 scripting experience with UDK, but I think what I'm trying to do is fairly simple. I want to define a variable in script that I can then access in Kismet.
This is what I have so far:
MyGameInfo.uc looks like this
class MyGameInfo extends UDKGame;
defaultproperties{
PlayerControllerClass=class'MyGameInfo.MyPlayerController'
}
event InitGame( string Options, out string Error )
{
// Call the parent(i.e. GameInfo) InitGame event version and pass the parameters
super.InitGame( Options, Error );
// Unreal Engine 3
`log( "Hello, world!" );
}
MyPlayerController.uc looks like:
class MyPlayerController extends UDKPlayerController;
var() localized string LangText;
defaultproperties{
LangText="asdfasdf";
}
Then, in Kismet I'm using Get Property, with player 0 as the target, attempting to get property LangText. I have the string output going to Draw Text (and yes, I made sure to set a font).
It looks like this:
I feel like I'm really close, but no text shows up in the Draw Text. Any ideas?
Also, why am I trying to do this? For localization purposes. As far as I can tell, there's no easy way in Kismet to use localized strings for Draw Text. My thinking is just to create a localized string for each piece of dialog and then call those strings from Kismet as needed.
You need to make sure you added a Font asset from the content browser in the DrawText properties, and check it is actually placed on the screen (try Offset 0,0 for centered text)
Also, I think that DrawText doesn't work in UTGAME - in case that's your gametype. It works in UDKGame.
And if you have ToggleCinematic mode enabled, then check Disable HUD isn't on.
Test the DrawText with a regular string first...
Try using Player Spawned event instead of Level Loaded, as it may fire too fast for the player to have been added in the game yet.
I have read in msdn RenderStream that we can call RenderStream multiple time to make long filter chain. I have following filter chain:
Capture Filter -> Sample Grabber -> Transformation Filter -> Video Mixing Renderer9
I'm trying to do the same using RenderStream programmatically.
pBuid->RenderStream(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,pCap,pSampleGrabber,pTransformFilter);
pBuid->RenderStream(NULL,NULL,pTransformFilter,NULL,pVMRender);
But, above code does not work. After executing, first RenderStream it shows console window(win32) and does nothing.
Please help me how can I render Capture->Sample Grabber->Transform Filter->Renderer.
Resolved the issue:
#CPlusSharp,
you were right it was media type issue. I set proper media tyep for AM_MEDIATYPE.
Thanks to all for help :)
You need to use Pin_Category_preview if you are using videoRenderer. Try the following:
pBuid->RenderStream(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,pCap,pSampleGrabber,pTransformFilter);
pBuid->RenderStream(&PIN_CATEGORY_PREVIEW,&MEDIATYPE_Video,pCap,null,null); //the preview pin automatically connects to the renderer.