我有一个像这样的UITabBarItem:
_Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:nil tag:0];
Run Code Online (Sandbox Code Playgroud)
但是没有标题会删除可访问性和KIF测试所需的标签.我找到的另一种方法是设置标题并将其移出屏幕,但这似乎是一个hacky解决方案:
_Controller.tabBarItem.title = @"Foo";
_Controller.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, 200);
Run Code Online (Sandbox Code Playgroud)
是否可以使UITabBarItem没有标题,但仍然有可访问性标签?
编辑以添加标签栏和背景按钮代码的完整代码:
- (void) loadViewController {
_Controller = [[UIViewController alloc] init];
UIImage *normalImage = [UIImage imageNamed:@"bar.png"];
UIImage *selectedTabImage = [UIImage imageNamed:@"barHover.png"];
[self addCenterButtonWithImage:normalImage
highlightImage:selectedTabImage];
_Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:nil tag:0];
}
// Create a custom UIButton and add it to the center of our tab bar
-(void) addCenterButtonWithImage:(UIImage*)buttonImage highlightImage:(UIImage*)highlightImage
{
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
[button setBackgroundImage:buttonImage …Run Code Online (Sandbox Code Playgroud) 我经常需要等待一个AJAX调用,在完成加载后将文本添加到页面上的元素中.我理解如何使用WebDriverWait等待元素中存在特定文本,但我不知道如何等待任何文本存在.我试图避免一个继续检查元素的文本的while循环== ''.
这是我用来查找特定文本的内容:
try:
WebDriverWait(self.driver, 10).until(EC.text_to_be_present_in_element((By.ID, 'myElem'), 'foo'))
except TimeoutException:
raise Exception('Unable to find text in this element after waiting 10 seconds')
Run Code Online (Sandbox Code Playgroud)
有没有办法检查任何文本或非空字符串?